[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-janitors] #1465: get-keyword fails to operate correctly if keyw
From: |
Chicken Trac |
Subject: |
[Chicken-janitors] #1465: get-keyword fails to operate correctly if keywords in first and second arguments come from different environments |
Date: |
Wed, 23 May 2018 18:08:24 -0000 |
#1465: get-keyword fails to operate correctly if keywords in first and second
arguments come from different environments
----------------------------+--------------------------------
Reporter: jrobbins | Owner:
Type: defect | Status: new
Priority: major | Milestone: someday
Component: core libraries | Version: 4.13.0
Keywords: | 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)
#f
((car default))
)
)
)
)
}}}
--
Ticket URL: <https://bugs.call-cc.org/ticket/1465>
CHICKEN Scheme <https://www.call-cc.org/>
CHICKEN Scheme is a compiler for the Scheme programming language.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Chicken-janitors] #1465: get-keyword fails to operate correctly if keywords in first and second arguments come from different environments,
Chicken Trac <=