[racket] syntax-parse #:with directive followed by #:declare
This program:
#lang racket
(require (for-syntax syntax/parse))
(define-syntax (test stx)
(syntax-parse stx
[(_ x)
#:with y #'x
#:declare x expr
#'x]))
produces the error:
syntax-parse: declared pattern variables do not appear in pattern in:
(syntax-parse stx ((_ x) #:with y (syntax x) #:declare x expr (syntax x)))
x
With the #:with, the #:declare no longer sees the x variable. The
error goes away if the #:with and #:declare are flipped. I extended
the example with more variables and it seems like #:declare only sees
the variables in the #:with pattern and not the main pattern.
Is this a bug or expected behavior?