Summary
get-keyword fails to operate correctly if keywords in first and second arguments come from different environments
Metadata
- Id: cb008ba67fec4b92ae5f25e058ea03d08f2535bb
- Trac id: 1465
- Type: defect
- Reporter: jrobbins
- Owner:
- Cc:
- Status: new
- Component: core libraries
- Estimated difficulty: trivial
- Resolution:
- Priority: major
- Milestone: someday
- Version: 4.13.0
- Changetime: 2018-05-23 20:08:24 UTC
- Created: 2018-05-23 20:08:24 UTC
- Keywords:
Description
Run the following code in csi, and you'll get a failed assertion:
(define-syntax keyword-from-syntax (syntax-rules () ((_) #:k))) (assert (get-keyword (keyword-from-syntax) '(h i j #:k l)))
This should return l, but instead it returns #f. The bug occurs when a keywords from different environments are compared; the #:k from the syntax-rules is not being treated as equal to the #:k from the normal code for some reason.
A working replacement (and the replacement I use in my code) could be as follows:
(define (get-keyword kw args . default)
(let (
(tail (memq kw args))
)
(if (and tail (not (null? (cdr tail))))
(cadr tail)
(if (null? default)
#f
((car default))
)
)
)
)