Skip to content

Commit

Permalink
[#140] fix for
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Nov 1, 2019
1 parent 9b70708 commit 4546b4a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion resources/SCI_VERSION
@@ -1 +1 @@
0.0.11-alpha.5
0.0.11-alpha.6
6 changes: 3 additions & 3 deletions src/sci/impl/for_macro.cljc
Expand Up @@ -11,6 +11,7 @@
(throw (new #?(:clj IllegalArgumentException :cljs js/Error)
"for requires an even number of forms in binding vector"))))

;; see clojurescript core.cljc defmacro for
(defn expand-for
[_ [_ seq-exprs body-expr]]
(assert-args seq-exprs body-expr)
Expand Down Expand Up @@ -47,9 +48,8 @@
`(fn ~giter [~gxs]
(lazy-seq
(loop [~gxs ~gxs]
(let [~bind (~'first ~gxs)]
(~'when ~bind
~(do-mod mod-pairs))))))
(when-first [~bind ~gxs]
~(do-mod mod-pairs)))))
#_"inner-most loop"
(let [gi (gensym "i__")
gb (gensym "b__")
Expand Down
2 changes: 2 additions & 0 deletions test/sci/core_test.cljc
Expand Up @@ -366,6 +366,8 @@
(deftest for-test
(is (= '([1 4] [1 6])
(eval* "(for [i [1 2 3] :while (< i 2) j [4 5 6] :when (even? j)] [i j])")))
(is (= (for [[_ counts] [[1 [1 2 3]] [3 [1 2 3]]] c counts] c)
(eval* "(for [[_ counts] [[1 [1 2 3]] [3 [1 2 3]]] c counts] c)")))
(is (thrown-with-msg? #?(:clj Exception :cljs js/Error)
#"vector"
(eval* "(for 1 [i j])")))
Expand Down

0 comments on commit 4546b4a

Please sign in to comment.