From 0a1d902f46f89fca0df8bae122cedd9c5919d7ba Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 26 Sep 2020 13:28:29 -0500 Subject: [PATCH] Fix #477 Make the walk function preserve bracket type, which should fix threading macro behavior when threading into bracketed expressions. --- src/boot/boot.janet | 5 ++++- test/suite0010.janet | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/boot/boot.janet b/src/boot/boot.janet index a31785bb..636f2b24 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -1141,7 +1141,10 @@ :table (walk-dict f form) :struct (table/to-struct (walk-dict f form)) :array (walk-ind f form) - :tuple (tuple/slice (walk-ind f form)) + :tuple (let [x (walk-ind f form)] + (if (= :parens (tuple/type form)) + (tuple/slice x) + (tuple/brackets ;x))) form)) (undef walk-ind) diff --git a/test/suite0010.janet b/test/suite0010.janet index 62ef3bab..feb44510 100644 --- a/test/suite0010.janet +++ b/test/suite0010.janet @@ -61,4 +61,8 @@ (assert-no-error "import macro 1" (macex '(import a :as b :fresh maybe))) (assert (deep= ~(,import* "a" :as "b" :fresh maybe) (macex '(import a :as b :fresh maybe))) "import macro 2") +# #477 walk preserving bracket type +(assert (= :brackets (tuple/type (postwalk identity '[]))) "walk square brackets 1") +(assert (= :brackets (tuple/type (walk identity '[]))) "walk square brackets 2") + (end-suite)