Changes the rules so that multisym symbols whose tail pieces start
with a digit contain `&`, such as `foo.0123:&&&` are allowed. This
commit doesn't fix the other issue with symbols that end in `.`.
---
src/fennel/compiler.fnl | 2 +-
src/fennel/parser.fnl | 3 ---
src/fennel/repl.fnl | 1 -
test/failures.fnl | 2 --
test/misc.fnl | 4 ++++
5 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/fennel/compiler.fnl b/src/fennel/compiler.fnl
index 8b2b296..94d94e0 100644
--- a/src/fennel/compiler.fnl
+++ b/src/fennel/compiler.fnl
@@ -184,7 +184,7 @@ rather than generating new one."
(let [name (tostring symbol)
macro? (?. ?opts :macro?)]
;; we can't block in the parser because & is still ok in symbols like &as
- (assert-compile (not (name:find "&")) "invalid character: &" symbol)
+ (assert-compile (not= "&" (name:match "[&.:]")) "invalid character: &" symbol)
(assert-compile (not (name:find "^%.")) "invalid character: ." symbol)
(assert-compile (not (or (. scope.specials name)
(and (not macro?) (. scope.macros name))))
diff --git a/src/fennel/parser.fnl b/src/fennel/parser.fnl
index 8e1b0ff..f537f2b 100644
--- a/src/fennel/parser.fnl
+++ b/src/fennel/parser.fnl
@@ -310,9 +310,6 @@ Also returns a second function to clear the buffer in the byte stream."
(fn col-adjust [pat] (- (rawstr:find pat) (utils.len rawstr) 1))
(if (and (rawstr:match "^~") (not= rawstr "~="))
(parse-error "invalid character: ~")
- (rawstr:match "%.[0-9]")
- (parse-error (.. "can't start multisym segment with a digit: " rawstr)
- (col-adjust "%.[0-9]"))
(and (rawstr:match "[%.:][%.:]") (not= rawstr "..")
(not= rawstr "$..."))
(parse-error (.. "malformed multisym: " rawstr)
diff --git a/src/fennel/repl.fnl b/src/fennel/repl.fnl
index 895bb2e..7dc8dbb 100644
--- a/src/fennel/repl.fnl
+++ b/src/fennel/repl.fnl
@@ -9,7 +9,6 @@
(local compiler (require :fennel.compiler))
(local specials (require :fennel.specials))
(local view (require :fennel.view))
-(local unpack (or table.unpack _G.unpack))
(var depth 0)
diff --git a/test/failures.fnl b/test/failures.fnl
index 2b02543..1283e7d 100644
--- a/test/failures.fnl
+++ b/test/failures.fnl
@@ -115,8 +115,6 @@
(assert-fail (let [t {:a 1}] (+ t.a BAD)) "BAD")
(assert-fail (local 47 :forty-seven) "unable to bind number 47")
(test-failures {"(local a~b 3)" "invalid character: ~"
- "(let [t []] (set t.47 :forty-seven))"
- "can't start multisym segment with a digit: t.47"
"(let [t []] (set t.:x :y))" "malformed multisym: t.:x"
"(let [t []] (set t::x :y))" "malformed multisym: t::x"
"(let [t []] (set t:.x :y))" "malformed multisym: t:.x"
diff --git a/test/misc.fnl b/test/misc.fnl
index 97a8469..4435ac3 100644
--- a/test/misc.fnl
+++ b/test/misc.fnl
@@ -151,6 +151,10 @@
tbl (fennel.eval code)]
(t.= (. tbl 8) 8)))
+(fn test-multisyms []
+ (t.is (pcall fennel.eval "(let [x {:0 #$1 :& #$1}] (x:0) (x:&) (x.0) (x.&))" {:allowedGlobals false})
+ "Expected to be able to use multisyms with digits and & in their second part"))
+
{: setup
: test-empty-values
--
2.43.0