This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-13
Channels
- # announcements (13)
- # beginners (52)
- # bitcoin (2)
- # calva (2)
- # cider (7)
- # clara (1)
- # clj-commons (11)
- # clj-kondo (6)
- # cljdoc (14)
- # clojure (68)
- # clojure-belgium (1)
- # clojure-denmark (6)
- # clojure-europe (57)
- # clojure-nl (2)
- # clojure-norway (10)
- # clojure-uk (3)
- # clojurescript (7)
- # code-reviews (17)
- # conjure (1)
- # cursive (5)
- # dev-tooling (11)
- # emacs (9)
- # fulcro (12)
- # hugsql (20)
- # introduce-yourself (6)
- # joyride (2)
- # leiningen (1)
- # lsp (61)
- # malli (30)
- # missionary (11)
- # nbb (6)
- # off-topic (26)
- # portal (5)
- # practicalli (5)
- # re-frame (8)
- # releases (8)
- # sci (21)
- # shadow-cljs (3)
- # sql (17)
- # squint (1)
- # xtdb (3)
I’m trying to display errors in a nice way and in simple cases this works by using line
and col
info of the exception but when something is wrapped in a macro this information seems to be lost. I’ve seen this in Sci, but I ’ve seen it in Babashka too. I wonder if this can be fixed. 🧵
➜ ~ bb -e 'foo'
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: Could not resolve symbol: foo
Location: <expr>:1:1
Phase: analysis
----- Context ------------------------------------------------------------------
1: foo
^--- Could not resolve symbol: foo
➜ ~ bb -e '(defmacro bar [& body] `(do ~@body)) (bar foo)'
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: Could not resolve symbol: foo
Phase: analysis
(sci/eval-string "foo")
clojure.lang.ExceptionInfo: Could not resolve symbol: foo
{:type :sci/error, :line 1, :column 1, :file nil, :phase "analysis"}
vs
(sci/eval-string "(do (defmacro a-macro [& body] `(do ~@body)) (a-macro foo))")
clojure.lang.ExceptionInfo: Could not resolve symbol: foo
{:type :sci/error, :line nil, :column nil, :file nil, :phase "analysis"}
In clojure
➜ ~ clj -e '(defmacro bar [& body] `(do ~@body)) (bar foo)'
WARNING: Implicit use of clojure.main with options is deprecated, use -M
#'user/bar
Syntax error compiling at (REPL:1:38).
Unable to resolve symbol: foo in this context
I’m guessing this issue is related https://github.com/babashka/sci/issues/775
There have been various improvement in this area after people posted an issue about it - welcome to do it again! :) The 775 issue isn't related
Note that when you wrap (bar foo)
with a vector or so, the error report gives a decent location. I think the issue can be solved
Ah cool, I’ll try that
I’ll create an issue later 😅
Thanks and have a good night & weekend!
I'm on a train ride now, I'll look into it now, thanks for giving me something to do ;)
haha you’re welcome 💪
wrapping it with a vector works and helps me further for now!
bb -e '[ (defmacro bar [& body] `(do ~@body)) (bar foo)]'
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: Could not resolve symbol: foo
Data: {:type :sci/error, :line nil, :column nil, :file "<expr>", :phase "analysis"}
Location: <expr>:1:40
Phase: analysis
----- Context ------------------------------------------------------------------
1: [ (defmacro bar [& body] `(do ~@body)) (bar foo)]
^--- Could not resolve symbol: foo
----- Stack trace --------------------------------------------------------------
user - <expr>:1:40
Nearing the end of my train ride. I fixed it in SCI branch fix-top-level-macro-error-loc
I think. Need to add a test for it, but with babashka I now get error locations
When the master build finishes you can obtain the new bb with:
bash <(curl ) --dev-build --dir /tmp
Thank you so much! I’ll test it properly in the coming days. The master build works for me.
/tmp/bb -e '(defmacro bar [& body] `(do ~@body)) (bar (bar :aaa (let [a 1 b 2 c 4 c 5] foo)))'
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: Could not resolve symbol: foo
Data: {:type :sci/error, :line 1, :column 53, :file "<expr>", :phase "analysis"}
Location: <expr>:1:53
Phase: analysis
----- Context ------------------------------------------------------------------
1: (defmacro bar [& body] `(do ~@body)) (bar (bar :aaa (let [a 1 b 2 c 4 c 5] foo)))
^--- Could not resolve symbol: foo
This feedback is a huge improvement! I’ll check in my own code laterThat example already worked well with bb 1.0.169, but this example didn't:
-e '(defmacro bar [& body] `(do ~@body)) (bar foo)'
Ah ok. I saw the line and col were pointing to the wrapping macro and not exactly to foo
. So I was nesting it in order to see what would happen. Didn't realize this was a different case that was already working
I think everything works as expected now. Had some other issue to solve before i could verify properly 😅