Refinement of Clojure error phases and location reporting

Description

Problems to address:

  • Refine error phases to separate "syntax checking" from the phase itself (in compile and macroexpand)

  • Use phase names that better reflect the actual location of the error (ie :read-source rather than :read)

  • Break ex-str into two parts: ex-triage (semantic analysis of Throwable data) and ex-str (string-making) to increase options for reuse by other tools

  • For execution errors, report the line in the stack reflecting the user operation (outside core), rather than in the guts of core (RT.java, etc)

  • Accept meta on repl forms (:clojure.core/eval-file or :line) and use that as if it was the source file/line.

Patch: clj-2420-5.patch
Screened: clj-2420-5.patch

Changes:

  • Compiler.java

    • CompilerException - adjust phase names

    • remove private isMacroSyntaxCheck() - now covered at point of capture

    • set correct compiler exception phase. currently we bucket all compile errors into :compile-syntax-check. later, we can refine compiler errors and separate some into :compilation. Right now, there is no consistent use of exceptions or way to do this. The code is all ready to work when those change are made.

    • modify eval() to look for and bind file and source-path based on meta :clojure.core/eval-file

  • main.clj

    • removed some commented out dead code

    • added predicate to determine whether stack frame class is a core class

    • added renumbering-read to allow a re-read with line number set from first read

    • removed init-cause (no longer needed)

    • added ex-triage, which takes Throwable->map data and emits an error analysis

    • made ex-str (new in 1.10) take ex-triage data as input and produce a string

    • repl-caught - now uses Throwable->map, ex-triage

    • repl - uses new phase name, removes file setting (moved to Compiler.eval())

  • repl.clj - updated phases to report special message for pst

Also see attached error-results.txt file showing output of a set of examples in each phase. Additional manual tests were run against errors reporting from within files, rather than at repl.

Environment

None

Activity

Show:
Alex Miller
October 31, 2018, 8:31 PM

-2 patch adds some new function meta, some doc string changes in ex-triage, and handles the case where the JVM omits the stack.

Alex Miller
November 1, 2018, 9:55 PM

-3 patch has some fixes in using meta :file and :line annotations

Alex Miller
November 2, 2018, 5:59 PM

-4 has some more subtle fixes in supporting :file/:line meta

Completed

Assignee

Unassigned

Reporter

Alex Miller

Approval

Ok

Patch

Code and Test

Fix versions

Affects versions

Priority

Major
Configure