Can rephrase help with exceptions like https://clojurians.slack.com/archives/C03S1KBA2/p1780496934956719 >
Unhandled java.lang.ClassCastException
> class user$build_adj$fn__11004$fn__11005 cannot be cast to class clojure.lang.IPersistentCollection
Actual problem:
> I think you want
> (mapv (fn [_] #{}) (range n))
> instead of
> (mapv (fn [_] #()) (range n))
Currently:
user=> (reduce (fn [acc v] (update acc v conj v)) *1 (range n))
Expected IPersistentCollection, but was given user$eval18295$fn__18296$fn__18297, at user/eval18301$fn (REPL:1) - runtime error (unexpected type).not bad
I don't currently do any symbol demunging that would improve that.
that's definitely more helpful.
Part of the difficulty with Jim's specific error is that you have an anonymous function #() inside an anonymous function (fn [..] ..). Compound that with the way the REPL wraps things in evalNNN.
ultimately, I think the best experience will require hacking the compiler as well as incorporating ideas from something like flowstorm
Yeah, I was pleased to hear Alex talk about a potential dev vs prod mode that might allow for more checking and better errors in dev mode.
I think jpmonettas suggested a compiler fork too -- but I don't want to maintain that (and it wouldn't "compose" with other compiler forks).
Rephrase is meant to show that you can improve a lot of error messages to some extent without going too deep. I use it all the time, in all my projects now, and if I hit an ugly error, I try to figure out a way to rephrase it. But I don't hit a lot of the errors that beginners do these days (15+ years of Clojure).