~technomancy/fennel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH fennel v2] Relax multisym identifier requirements

Details
Message ID
<fB-JmdmQXI1-4pZvUKW677Fd2HRYzd4E4IOoOEiW_Qz1NufWjRbCUIAonjTSx7nbLPnuV3Thh8AhT21KHNy8wswcvwiLRsq7utAxnUEgXnA=@protonmail.com>
DKIM signature
pass
Download raw message
Patch: +5 -7
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

[fennel/patches/.build.yml] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CZ21K6OL9OCE.3O5RWHS5UY9J4@fra01>
In-Reply-To
<fB-JmdmQXI1-4pZvUKW677Fd2HRYzd4E4IOoOEiW_Qz1NufWjRbCUIAonjTSx7nbLPnuV3Thh8AhT21KHNy8wswcvwiLRsq7utAxnUEgXnA=@protonmail.com> (view parent)
DKIM signature
missing
Download raw message
fennel/patches/.build.yml: SUCCESS in 11s

[Relax multisym identifier requirements][0] v2 from [XeroOl][1]

[0]: https://lists.sr.ht/~technomancy/fennel/patches/49377
[1]: xerool@protonmail.com

✓ #1147323 SUCCESS fennel/patches/.build.yml https://builds.sr.ht/~technomancy/job/1147323
Details
Message ID
<87le7qguzt.fsf@hagelb.org>
In-Reply-To
<fB-JmdmQXI1-4pZvUKW677Fd2HRYzd4E4IOoOEiW_Qz1NufWjRbCUIAonjTSx7nbLPnuV3Thh8AhT21KHNy8wswcvwiLRsq7utAxnUEgXnA=@protonmail.com> (view parent)
DKIM signature
pass
Download raw message
XeroOl <xerool@protonmail.com> writes:

> 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 `.`.

Looks great; thanks. I've applied and pushed this and the macroexpand
hook patch.

I think at this point, the only thing left for 1.4.1 is to deal with
symbols ending in . plus maybe https://todo.sr.ht/~technomancy/fennel/194
and https://todo.sr.ht/~technomancy/fennel/195.

thanks!
Phil
Reply to thread Export thread (mbox)