[racket] syntax-parse #:with directive followed by #:declare
On 06/09/2014 02:40 PM, Stephen Chang wrote:
> 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?
It's the expected behavior. I'll try to improve the error message.
Ryan