This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-07-08
Channels
- # announcements (16)
- # beginners (22)
- # calva (3)
- # cider (17)
- # clojure (2)
- # clojure-berlin (1)
- # clojure-denmark (4)
- # clojure-dev (4)
- # clojure-europe (22)
- # clojure-madison (1)
- # clojure-nl (2)
- # clojure-norway (34)
- # clojure-sweden (3)
- # clojure-uk (3)
- # clojurescript (9)
- # datomic (7)
- # deps-new (1)
- # events (1)
- # fulcro (1)
- # hyperfiddle (10)
- # lsp (43)
- # missionary (1)
- # off-topic (27)
- # pedestal (10)
- # polylith (1)
- # reitit (4)
- # releases (1)
- # squint (18)
- # xtdb (8)
Is there something like M-x cider-inspect
for cider-stacktrace? Say my point is at saved-exception|
, I would run M-x imaginary-cider-stacktrace-at-point and the exception would show up in cider-stacktrace-mode.
Fwiw evalling (throw saved-exception)
works fine, I just thought it’d be a neat feature 😄
On the *cider-error*
buffer, if one clicks or hits RET on the exception classname, cider inspector will pop up
Is that what you would want? Or do you mean in the opposite direction
Got it
I created https://github.com/clojure-emacs/orchard/issues/227 earlier this year which probably be equivalent - if exceptions are rendered nicely within the Inspector and they're actionable (click to open as file), then *cider-error*
wouldn't have a specific advantage, right?
Nice. Implementing that ticket is outside my immediate capacity It may strike @U06PNK4HG's fancy
I have run into a bug with... something, I don't know what. I picked this channel because it seemed the most relevant. I have this code as part of a function
(match form
(['try & body] :seq)
(let [[body extra-clauses] (split-with (complement catch-clause?) body)
body (reduce thread* value-symbol body)
extra-clauses (mapv (fn [clause]
(println "clause" clause (class clause))
(match clause
(['catch kind name & body] :seq)
(let []
(println "catch body" body)
`(catch ~kind ~name
(println "correct")
~@body))
:else
(do (println "finally clause")
clause)))
extra-clauses)]
(do
(println extra-clauses)
`(let [~value-symbol ~value]
(try ~body ~@extra-clauses))))
When I make it run I get an unexpected result:
oskarkv.utils.threading> (+>$ 1 (try (/ 0) (catch Exception e inc)))
clause (catch Exception e inc) clojure.lang.PersistentList
finally clause
[(catch Exception e inc)]
#function[clojure.core/inc]
I didn't expect to see the "finally clause" there. So I tried to debug it, with cider-debug-defun-at-point
. If I run through it with debug on, I get a different result:
oskarkv.utils.threading> (+>$ 1 (try (/ 0) (catch Exception e inc)))
clause (catch Exception e inc) clojure.lang.PersistentList
body (inc)
[(catch Exception e (clojure.core/println correct) inc)]
correct
#function[clojure.core/inc]
This is what I expected all along. I did not change the code; I have tried debug on and off back and forth and I get these results every time. I also get the expected result if I copy the inner function to the REPL, like:
oskarkv.utils.threading> (def abc (fn [clause]
(println "clause" clause (class clause))
(match clause
(['catch kind name & body] :seq)
(let []
(println "catch body" body)
`(catch ~kind ~name
(println "correct")
~@body))
:else
(do (println "finally clause")
clause))))
#'oskarkv.utils.threading/abc
oskarkv.utils.threading> (abc '(catch Exception e inc))
clause (catch Exception e inc) clojure.lang.PersistentList
catch body (inc)
(catch Exception e (clojure.core/println "correct") inc)
Does anyone have any idea of what is wrong, and what I can do about it?Nothing comes to mind. Perhaps I'd replace match
with something that is easier to reason about
I'm afraid you'll need a smaller reproducible example for somebody to be able to figure this out.
is it because of the particular body name or maybe because there's a nested match
?
Either way, somewhat concerning that cider fails to keep up with that behavior
If a local is bound to a name, using that name in a match clause matches only against what the local is bound to.