sci

2025-01-03T16:23:43.879739Z

Is there a way to get the (correct) line and column info from the form {a a} when a is undefined? E.g.

(try (sci.core/eval-string "  a  ") (catch Exception e (ex-data e))) ;=> {... :line 1 :column 3} ; correct

(try (sci.core/eval-string "{a a}") (catch Exception e (ex-data e))) ;=> {... :line nil :column nil}

(try (sci.core/eval-string "(try
 {a a} (catch ^:sci/error Exception e (throw e)))") (catch Exception e (ex-cause e))) ;=> {... :line 1 :column 1} ; incorrect, always 1 and 1
In babashka you can see the above as well:
bb -e "

{a a}

"
----- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  Could not resolve symbol: a
Phase:    analysis
Clojure itself also seem to have issues with reporting this kind of error, but it would be nice if Sci could do this

borkdude 2025-01-03T16:24:56.579969Z

Only seq forms (lists) have positional metadata so in this case, unfortunately not

borkdude 2025-01-03T16:25:33.318629Z

It seems Clojure has the same behavior:

user=> {:a (+ 1 a)}
Syntax error compiling at (REPL:1:5).
Unable to resolve symbol: a in this context
user=> {:a a}
Syntax error compiling at (REPL:0:0).

borkdude 2025-01-03T16:25:42.303909Z

0:0 means: I don't know, I think

2025-01-03T16:45:05.085839Z

Ok too bad, thanks for confirming

2025-01-03T17:24:00.158179Z

It is a different case, but it is interesting that this gives accurate line information as it complains about a duplicate key. I guess that's an error from one level before, the edn parsing

(sci.core/eval-string "
#{ a a }")

borkdude 2025-01-03T17:57:39.539389Z

right, that'a coming from the reader