Using expr/c to attach a contract to a macro sub-pattern doesn't seem to
work with ~optional, even when the attribute is bound with #:defaults.

For example, this program:

> #lang racket

(require (for-syntax syntax/parse))
> (define-syntax (example stx)
>   (syntax-parse stx
>     [(_ (~optional (~seq #:return val)
>                    #:defaults ([val #'42])))
>      #:declare val (expr/c #'(or/c list? #f))
>      #'val.c]))
> (example)

reports the following error:

> val.c: bad attribute value for syntax template
>   attribute value: #f
>   expected for attribute: syntax
>   sub-value: #f
>   expected for sub-value: syntax in: val.c

Is there a better way to do this?

You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
For more options, visit

Reply via email to