mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Fix crash on #nil in syntaxes
In 3.0.7 (after 0cc7991855
"Ensure
that (syntax ()) results in ("), the use of #nil in syntax-rules
expansions like this:
(define-syntax foo
(syntax-rules ()
((_ x) (eq? #nil x))))
(foo #t)
could cause a crash that looks like this:
ice-9/psyntax.scm:2795:12: In procedure syntax-violation:
Syntax error:
unknown location: unexpected syntax in form ()
To fix it, add another special case (the commit mentioned above
special-cased the empty list) to preserve #nil
* module/ice-9/psyntax.scm (gen-syntax): Preserve #nil.
* test-suite/tests/syntax.test: Test #nil in syntax expansions.
Closes: 49305
This commit is contained in:
parent
118ee0c50b
commit
d79a226359
2 changed files with 11 additions and 0 deletions
|
@ -2157,6 +2157,7 @@
|
|||
(lambda ()
|
||||
(gen-syntax src #'(e1 e2 ...) r maps ellipsis? mod))
|
||||
(lambda (e maps) (values (gen-vector e) maps))))
|
||||
(x (eq? (syntax->datum #'x) #nil) (values '(quote #nil) maps))
|
||||
(() (values '(quote ()) maps))
|
||||
(_ (values `(quote ,e) maps))))))
|
||||
|
||||
|
|
|
@ -1684,6 +1684,16 @@
|
|||
(hash interpreted most-positive-fixnum)
|
||||
(hash compiled most-positive-fixnum))))
|
||||
|
||||
(with-test-prefix "#nil in syntaxes"
|
||||
(pass-if-equal "does not crash"
|
||||
42
|
||||
(let ()
|
||||
(define-syntax foo
|
||||
(syntax-rules ()
|
||||
;; In 3.0.7 this would crash with
|
||||
;; unknown location: unexpected syntax in form ()
|
||||
((_ x) (when (eq? x #nil) 42))))
|
||||
(foo #nil))))
|
||||
|
||||
;;; Local Variables:
|
||||
;;; eval: (put 'pass-if-syntax-error 'scheme-indent-function 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue