Closed jbclements closed 4 years ago
My syntax-parse-fu is not up to snuff. I thought that this would have fixed the error:
(define-splicing-syntax-class kind-kw
#:description "#:kind keyword"
(pattern (~optional
(~seq #:kind (~var kind (expr/c #'string? #:name "#:kind argument")))
#:defaults ([kind #'#f]))))
replacing this definition of kind-kw, but I'm not seeing a new error when I make that change. Maybe @jeapostrophe or @rmculpepper wouldn't mind chiming in?
You need to use the c
attribute computed by expr/c
. Here's how I would write it:
(define-splicing-syntax-class kind-kw
#:attributes (kind) ;; Expr[String/#f]
#:description "#:kind keyword"
(pattern (~optional (~seq #:kind k))
#:declare k (expr/c #'string? #:name "#:kind argument")
#:with kind #'(~? k.c #f)))
Based on a quick glance, the rest of the module seems to just use the kind
attribute, so I changed that to get the contract-wrapped expression.
Sorry, I shouldn't have used #:declare
, since that change is unrelated to the fix. Here's the same code without #:declare
:
(define-splicing-syntax-class kind-kw
#:attributes (kind) ;; Expr[String/#f]
#:description "#:kind keyword"
(pattern (~optional (~seq #:kind (~var k (expr/c #'string? #:name "#:kind argument"))))
#:with kind #'(~? k.c #f)))
The #:attributes
line isn't strictly necessary here either, but it's useful documentation.
Thanks, @rmculpepper !
I'm not sure whether this is the kind of thing that merits an issue, but... running this code
results in an error that blames scribble code, rather than the user. To wit:
Do we care?