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

[PATCH] fix match not handling false pattern correctly

Message ID
DKIM signature
Download raw message
Patch: +10 -3
 src/fennel/macros.fnl | 6 ++++--
 test/macro.fnl        | 7 ++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/fennel/macros.fnl b/src/fennel/macros.fnl
index b78dad0..ec9f4c7 100644
--- a/src/fennel/macros.fnl
+++ b/src/fennel/macros.fnl
@@ -369,8 +369,10 @@ introduce for the duration of the body if it does match."
        seconds []
        res []]
    (for [i 1 (length seq) 2]
      (table.insert firsts (or (. seq i) 'nil))
      (table.insert seconds (or (. seq (+ i 1)) 'nil)))
      (let [first (. seq i)
            second (. seq (+ i 1))]
        (table.insert firsts (if (not= nil first) first 'nil))
        (table.insert seconds (if (not= nil second) second 'nil))))
    (each [i v1 (ipairs firsts)]
      (let [v2 (. seconds i)]
        (if (not= nil v2)
diff --git a/test/macro.fnl b/test/macro.fnl
index 76e08b6..3a295e3 100644
--- a/test/macro.fnl
+++ b/test/macro.fnl
@@ -199,7 +199,12 @@
                  (where tbl (. tbl :sieze)) :siezed)" :siezed
               "(match {:sieze :him}
                  (where tbl tbl.sieze tbl.no) :no
                  (where tbl tbl.sieze (= tbl.sieze :him)) :siezed2)" :siezed2}]
                  (where tbl tbl.sieze (= tbl.sieze :him)) :siezed2)" :siezed2
               "(match false false false true)" false
               "(match nil false false true)" true
               "(match true (where (or nil false true)) :ok :not-ok)" :ok
               "(match false (where (or nil false true)) :ok :not-ok)" :ok
               "(match nil (where (or nil false true)) :ok :not-ok)" :ok}]
    (each [code expected (pairs cases)]
      (l.assertEquals (fennel.eval code {:correlate true}) expected code))))

Message ID
<20210225161044.237068-1-andreyorst@gmail.com> (view parent)
DKIM signature
Download raw message
Nice catch; thanks. Applied and pushed!

Reply to thread Export thread (mbox)