Skip to content

Commit

Permalink
Fix #466: doseq with set! (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude authored Feb 15, 2024
1 parent c177ee6 commit e5584b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion src/squint/internal/macros.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down
5 changes: 3 additions & 2 deletions test/squint/compiler_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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 []))
Expand Down

0 comments on commit e5584b0

Please sign in to comment.