Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Oct 17, 2024
1 parent eadd17c commit a632d47
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
41 changes: 21 additions & 20 deletions src/sci/impl/for_macro.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,27 @@
c-sym (gensym "c")]
`(fn ~giter [~gxs]
(lazy-seq
(~allowed-loop [~gxs ~gxs]
(let [~gxs (seq ~gxs)]
(when ~gxs
(if (chunked-seq? ~gxs)
(let [~c-sym (chunk-first ~gxs)
size# (int (count ~c-sym))
~gb (chunk-buffer size#)]
(if (~allowed-loop [~gi (int 0)]
(if (< ~gi size#)
~(with-meta
`(let [~bind (nth ~c-sym ~gi)]
~(do-cmod mod-pairs))
loc)
true))
(chunk-cons
(chunk ~gb)
(~giter (chunk-rest ~gxs)))
(chunk-cons (chunk ~gb) nil)))
(let [~bind (first ~gxs)]
~(do-mod mod-pairs))))))))))))]
(~allowed-loop [~gxs ~gxs]
(let [~gxs ~(with-meta `(seq ~gxs)
loc)]
(when ~gxs
(if (chunked-seq? ~gxs)
(let [~c-sym (chunk-first ~gxs)
size# (int (count ~c-sym))
~gb (chunk-buffer size#)]
(if (~allowed-loop [~gi (int 0)]
(if (< ~gi size#)
~(with-meta
`(let [~bind (nth ~c-sym ~gi)]
~(do-cmod mod-pairs))
loc)
true))
(chunk-cons
(chunk ~gb)
(~giter (chunk-rest ~gxs)))
(chunk-cons (chunk ~gb) nil)))
(let [~bind (first ~gxs)]
~(do-mod mod-pairs))))))))))))]
`(let [iter# ~(emit-bind (to-groups seq-exprs))]
(iter# ~(second seq-exprs)))
))
5 changes: 3 additions & 2 deletions test/sci/error_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@

(deftest let-test
(doseq [[snippet [line col]]
[["(str (let [[a] 1] a))" [1 6]]
["(str (for [[a] [0]] :foo))" [1 6]]]]
[["(str (let [[a] 1] a))" [1 6]]
["(str (for [[a] [0]] :foo))" [1 6]]
["(str (for [[a] 1] (/ 1 a)))" [1 6]]]]
(try
(sci.core/eval-string snippet)
(is false)
Expand Down

0 comments on commit a632d47

Please sign in to comment.