mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 13:30:26 +02:00
psyntax's labels and marks now unique over a read/write boundary
* module/ice-9/psyntax.scm (gen-label, new-mark): Labels and marks need to be unique across read/write boundaries -- it's not sufficient for them to simply be unique within a process by virtue of (string #\i) constructing a new object. This used to mostly work before, because the collapsing of duplicate constants didn't catch many syntax-object cases -- but for some reason the attached test case brings out the problem. So switch to use gensyms. Potentially more costly, but it's what upstream psyntax does now. This bug took me fully two days to figure out. * module/ice-9/psyntax-pp.scm: Regenerated. * test-suite/tests/syncase.test ("serializable labels and marks"): Add test case.
This commit is contained in:
parent
ef73663576
commit
fd5985271f
3 changed files with 5287 additions and 5261 deletions
File diff suppressed because it is too large
Load diff
|
@ -787,9 +787,10 @@
|
|||
(syntax-rules ()
|
||||
((_ old new marks) (vector old new marks))))
|
||||
|
||||
;;; labels must be comparable with "eq?" and distinct from symbols.
|
||||
;;; labels must be comparable with "eq?", have read-write invariance,
|
||||
;;; and distinct from symbols.
|
||||
(define gen-label
|
||||
(lambda () (string #\i)))
|
||||
(lambda () (symbol->string (gensym "i"))))
|
||||
|
||||
(define gen-labels
|
||||
(lambda (ls)
|
||||
|
@ -820,7 +821,7 @@
|
|||
|
||||
(define-syntax new-mark
|
||||
(syntax-rules ()
|
||||
((_) (string #\m))))
|
||||
((_) (gensym "m"))))
|
||||
|
||||
;;; make-empty-ribcage and extend-ribcage maintain list-based ribcages for
|
||||
;;; internal definitions, in which the ribcages are built incrementally
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
;; affect code outside of this file.
|
||||
;;
|
||||
(define-module (test-suite test-syncase)
|
||||
:use-module (test-suite lib)
|
||||
:use-module ((srfi srfi-1) :select (member)))
|
||||
#:use-module (test-suite lib)
|
||||
#:use-module (system base compile)
|
||||
#:use-module ((srfi srfi-1) :select (member)))
|
||||
|
||||
(define-syntax plus
|
||||
(syntax-rules ()
|
||||
|
@ -82,3 +83,26 @@
|
|||
(pass-if "tail invocation"
|
||||
(equal? (alist ((foo 42) (tail '((bar . 66)))))
|
||||
'((foo . 42) (bar . 66))))))
|
||||
|
||||
(with-test-prefix "serializable labels and marks"
|
||||
(compile '(begin
|
||||
(define-syntax duplicate-macro
|
||||
(syntax-rules ()
|
||||
((_ new-name old-name)
|
||||
(define-syntax new-name
|
||||
(syntax-rules ()
|
||||
((_ . vals)
|
||||
(letrec-syntax ((apply (syntax-rules ()
|
||||
((_ macro args)
|
||||
(macro . args)))))
|
||||
(apply old-name vals))))))))
|
||||
|
||||
(define-syntax kwote
|
||||
(syntax-rules ()
|
||||
((_ arg1) 'arg1)))
|
||||
|
||||
(duplicate-macro kwote* kwote))
|
||||
#:env (current-module))
|
||||
(pass-if "compiled macro-generating macro works"
|
||||
(eq? (eval '(kwote* foo) (current-module))
|
||||
'foo)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue