~ chicken-core (chicken-5) e9cf59f8734ebdd0c774c223e574fd95dc022581
commit e9cf59f8734ebdd0c774c223e574fd95dc022581
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Sun Dec 23 20:44:51 2018 +0100
Commit: Peter Bex <peter@more-magic.net>
CommitDate: Sun Jan 20 12:32:23 2019 +0100
Preserve read/write invariance for symbols prefixed with "#!"
Only #!rest, #!key and #!optional should be written, since they are the
only symbols of that type recognised by the reader.
Signed-off-by: Evan Hanson <evhan@foldling.org>
Signed-off-by: Peter Bex <peter@more-magic.net>
diff --git a/NEWS b/NEWS
index a24d7e17..2b5e72dd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+5.0.2
+
+- Core libraries
+ - Read-write invariance of special symbols starting with #! other
+ than #!key, #!rest or #!optional is now preserved (#1572).
+
+
5.0.1
- Type system
diff --git a/library.scm b/library.scm
index 08c437df..6a089955 100644
--- a/library.scm
+++ b/library.scm
@@ -4501,8 +4501,7 @@ EOF
(not (and (fx> len 2)
(eq? (##core#inline "C_subchar" str 1) #\#)
(not (eq? (##core#inline "C_subchar" str 2) #\#)))))
- ;; #!rest, #!key etc
- (eq? (##core#inline "C_subchar" str 1) #\!))
+ (member str '("#!rest" "#!key" "#!optional")))
((specialchar? c) #f)
(else #t) ) )
(let ((c (##core#inline "C_subchar" str i)))
diff --git a/tests/syntax-tests.scm b/tests/syntax-tests.scm
index 663aa40e..bd88ec14 100644
--- a/tests/syntax-tests.scm
+++ b/tests/syntax-tests.scm
@@ -275,7 +275,15 @@
(t '#!rest (with-input-from-string "#!rest" read))
(t '#!rest (with-input-from-string "|#!rest|" read))
(t "#!rest" (with-output-to-string (lambda () (write '#!rest))))
+
+;; Non-special symbols starting with shebang
+(f (with-input-from-string "#!foo" read))
+(t '|#!foo| (with-input-from-string "|#!foo|" read))
+(t "|#!foo|" (with-output-to-string (lambda () (write '|#!foo|))))
+
+;; Namespaced symbols
(t "foo#bar" (with-output-to-string (lambda () (write 'foo#bar))))
+(t "##foo#bar" (with-output-to-string (lambda () (write '##foo#bar))))
;; These used to be treated specially, but now they just trigger an
;; "invalid sharp-sign read syntax" error.
Trap