Opened 6 years ago

#1465 new defect

get-keyword fails to operate correctly if keywords in first and second arguments come from different environments

Reported by: jrobbins Owned by:
Priority: major Milestone: someday
Component: core libraries Version: 4.13.0
Keywords: Cc:
Estimated difficulty: trivial


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)
        ((car default))

Change History (0)

Note: See TracTickets for help on using tickets.