Compiler.load() reports wrong exception phase


Compiler.load() throws CompilerException without setting the phase, which then uses default, which is :compile-syntax-check.

Given a file that, on load, will trigger an execution error:

Loading it will report as a compile exception, even though it's not a compile error (also, the location is wrong as it points to the invoke at the end):

This case occurs particularly in Cursive, which wraps the eval'ed expression in a form that is loaded by Cursive, so all evals from within a source file have this issue.

Cause: The cause of this is in Compiler.load() - that code catches Throwable and wraps it in a CompilerException, using the original constructor which has a default phase in it.

Proposed: Both CompilerExceptions and runtime exceptions should just flow out of load. Error triage already knows how to handle both cases correctly.

Note: related tickets here are (which introduced some of this long ago) and (whose tests are changed in this patch). The latter improved some whitespace consuming in the reader and those are good but these patches were all papering symptoms - the error triage changes in 1.10 are taking care of making good messages now.

However, this does change the content of the raw exception flowing from this case (no longer getting a wrapped exception with ex-data) and that may impact tools like CIDER. In general, tools should be using error triage dath from something like (-> e Throwable->map clojure.main/ex-triage). That call will return necessary source and line info.

Patch: clj-2529-2.patch

After, the error is execution, not compilation and it points to the line that actually caused the exception:




Alex Miller
November 2, 2020, 7:42 PM

I think is same problem as this.

Alex Miller
October 30, 2020, 7:51 PM

-2 patch is missing, I will look at this again

Your pinned fields
Click on the next to a field label to start pinning.


Alex Miller


Alex Miller








Affects versions

Fix versions