- changed status to resolved
Expanding ellipsis template raises an error if variables contains the same pattern variable
Issue #172
resolved
This raises an error:
(import (rnrs))
(define-syntax foo
(lambda (x)
(define (derive-it k s)
(let loop ((r '()) (s s))
(syntax-case s ()
(() (datum->syntax k r))
(((f a b) rest ...)
(loop (cons #'(f a b) (cons #'(f a b) r)) #'(rest ...))))))
(syntax-case x ()
((k (foo . bar) ...)
(with-syntax ((((foo a b) ...)
(derive-it #'k #'((foo . bar) ...))))
#''((foo a b) ...))))))
(foo (f a b)) ;; -> shoulr return ((foo a b) (foo a b))
The root cause is that foo
is bound in 2 places without renaming (so #t
in sense of bound-identifier=?
) and when expanding ellipsis the macro transformer collects both foo
variables and thinks one of the foo
doesn't have enough input.
In this case the first foo ...
has only (f)
however the second (newly created foo
) has (f f)
.
There might be 2 ways to resolve this:
- Rename the second
foo
(cleaner but more difficult to handle) - Ignore the first one
foo
when collecting the input form (dirty hack)
Comments (1)
-
reporter - Log in to comment
Considering shadowed pattern identifier during expanding ellipsis. (Fixes
#172)→ <<cset 5c6f90941562>>