Skip to content

Commit

Permalink
lock
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Oct 17, 2024
1 parent edefa18 commit fa7a275
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/sci/impl/namespaces.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@
(defn if-let*
([&form &env bindings then]
(if-let* &form &env bindings then nil))
([_&form _&env bindings then else & _oldform]
(let [form (bindings 0) tst (bindings 1)]
`(let [temp# ~tst]
(if temp#
(let [~form temp#]
~then)
([&form _&env bindings then else & _oldform]
(let [form (bindings 0) tst (bindings 1)
tmp (gensym "temp")]
`(let [~tmp ~tst]
(if ~tmp
~(with-meta `(let [~form ~tmp]
~then)
(meta &form))
~else)))))

(defn if-some*
Expand Down
3 changes: 2 additions & 1 deletion test/sci/error_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
[["(str (let [[a] 1] a))" [1 6]]
["(str (for [[a] [0]] :foo))" [1 6]]
["(str (for [[a] 1] (/ 1 a)))" [1 6]]
["(str (map (fn [[a]] a) [0]))" [1 11]] ]]
["(str (map (fn [[a]] a) [0]))" [1 11]]
["(str (if-let [[a] 0] a))" [1 6]]]]
(try
(sci.core/eval-string snippet)
(is false)
Expand Down

0 comments on commit fa7a275

Please sign in to comment.