Compiler.load() reports wrong exception phase

Description

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

Loading it will report as a compile exception (syntax error), even though it's really an execution error. not a compile error (also, the location points to (trigger) not the place where (/ 1 0) happens):

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 wraps runtime exceptions in a CompilerException uses the constructor that sets the default exception phase of :compilation.

Proposed: For runtime exceptions, set the exception phase to :execution.

Patch: clj-2529-3.patch

With the patch, the error is reported as an execution error and on the correct line:

 

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 better messages now.

Screened By: fogus

Environment

None

Attachments

2

Activity

Show:

Alex MillerFebruary 2, 2022 at 9:52 PM

Released in 1.11.0-beta1

Alex MillerJanuary 26, 2022 at 5:31 PM

FYI, I also checked a variety of other exceptions (read error, spec failure during macroexpansion, compile error) happening during load - those are all handled by other catch clauses and continue to do what they did before, which was correct.

Alex MillerNovember 2, 2020 at 7:42 PM

I think is same problem as this.

Alex MillerOctober 30, 2020 at 7:51 PM

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

Fixed

Details

Assignee

Reporter

Approval

Ok

Patch

Code

Priority

Affects versions

Fix versions

Created July 22, 2019 at 7:24 PM
Updated February 2, 2022 at 9:52 PM
Resolved February 2, 2022 at 9:52 PM