Skip to content

Commit

Permalink
More improved error locs (#948)
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude authored Oct 17, 2024
1 parent f77f1d2 commit 50f97f7
Show file tree
Hide file tree
Showing 3 changed files with 984 additions and 966 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
Loading

0 comments on commit 50f97f7

Please sign in to comment.