From e5584b0c45dd1109d2f9ac7417199732081091c3 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 15 Feb 2024 16:36:40 +0100 Subject: [PATCH] Fix #466: doseq with set! (#467) --- CHANGELOG.md | 4 ++++ src/squint/internal/macros.cljc | 2 +- test/squint/compiler_test.cljs | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f54e3187..b6ce9898 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ [Squint](https://github.com/squint-cljs/squint): Light-weight ClojureScript dialect +## v0.6.92 (2024-02-15) + +- #466: Fix `doseq` expression with `set!` in function return position + ## v0.6.91 (2024-02-14) - [#462](https://github.com/squint-cljs/squint/issues/462): Add `"exports"` field to `package.json` diff --git a/src/squint/internal/macros.cljc b/src/squint/internal/macros.cljc index 75bdba85..a5c1138e 100644 --- a/src/squint/internal/macros.cljc +++ b/src/squint/internal/macros.cljc @@ -269,7 +269,7 @@ (let [res (let [err (fn [& msg] (throw (ex-info (apply str msg) {}))) step (fn step [exprs] (if-not exprs - [true `(do ~@body)] + `(do ~@body) (let [k (first exprs) v (second exprs) subform (step (nnext exprs))] diff --git a/test/squint/compiler_test.cljs b/test/squint/compiler_test.cljs index 6e671e81..7c70c2c7 100644 --- a/test/squint/compiler_test.cljs +++ b/test/squint/compiler_test.cljs @@ -286,13 +286,14 @@ [3 3 1] [3 3 2] [3 3 3]] (js/eval s))))) (testing "return position in function" - (let [f (jsv! '(do (defn foo [x a] (doseq [i x] (swap! a conj i))) foo))] (is f) (let [a (jsv! '(atom [])) d (jsv! 'deref)] (f [1 2 3] a) - (is (eq #js [1 2 3] (d a)))))) + (is (eq #js [1 2 3] (d a))))) + (let [f (jsv! '(do (def a {}) (doseq [i [1 2 3]] (set! (.-foo a) (+ (or (.-foo a) 0) i))) a))] + (is (= 6 (aget f "foo"))))) (testing "iterate over object" (let [r (jsv! '(do (def a (atom []))