Skip to content

Commit

Permalink
map
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Oct 17, 2024
1 parent f77f1d2 commit edefa18
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/sci/impl/fns.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@

(defn ^{:private true}
maybe-destructured
[params body]
[params body loc]
(if (every? symbol? params)
(cons params body)
(loop [params params
Expand All @@ -159,8 +159,10 @@
(recur (next params) (conj new-params gparam)
(-> lets (conj (first params)) (conj gparam)))))
`(~new-params
(let ~lets
~@body))))))
~(with-meta
`(let ~lets
~@body)
loc))))))

(defn fn**
[form _ & sigs]
Expand All @@ -176,7 +178,7 @@
(str "Parameter declaration "
(first sigs)
" should be a vector")
(str "Parameter declaration missing"))
"Parameter declaration missing")
form)))
psig (fn* [sig]
;; Ensure correct type before destructuring sig
Expand Down Expand Up @@ -211,7 +213,7 @@
(concat (map (fn* [c] `(assert ~c)) pre)
body)
body)]
(maybe-destructured params body)))
(maybe-destructured params body (meta form))))
new-sigs (map psig sigs)
expr (with-meta
(if name
Expand Down
7 changes: 4 additions & 3 deletions test/sci/error_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@

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

0 comments on commit edefa18

Please sign in to comment.