Exceptions thrown in the top level ns form are reported without file or line number

Description

If there is an error in the `ns` form, an exception is thrown, which is not caught in `load`.

For example, with an invalid :only clause;

With the latest Clojure master as of Aug 24 2013, this generates the following exception, with no source file or line number except the one shown in clojure.core:

You can find a source file in your project if you painstakingly search through the stack trace, but it would be nice if it jumped out at you in the exception itself.

Patch: clj-939-v4.diff

Approach: The latest patch does not modify the behavior of any other exceptions thrown by the compiler. The throw-if function is only used in the load-related functions: this patch changes it to throw CompilerException instead of Exception. As a result, exceptions which occur while loading files will be decorated with file names and line/column numbers. The line/column numbers are not always accurate (see notes in attachment screen-clj-939.org) but the file names are correct.

This is an incremental improvement to compile-time error messages, but it does not solve some of the fundamental problems with reporting correct line/column numbers from errors thrown by the compiler.

Screened by: Stuart Sierra (re-screened by Alex for the specific comments by Rich)

Environment

None

Attachments

7

Activity

Show:

Alex Miller October 25, 2013 at 4:59 PM

Verified questioned bits have been removed and patch still applies cleanly and tests pass. Re-marking Screened with new patch.

Andy Fingerhut October 25, 2013 at 4:49 PM

Good catch, Alex. More coffee required here. Uploaded new clj-939-v4.diff in place of the previous one.

Alex Miller October 25, 2013 at 3:58 PM

Seems like the (declare list?) can go away too?

Andy Fingerhut October 25, 2013 at 3:06 PM

To: Operative Sierra
From: Chaos

Agent Hickey thwarted world domination plans yet again. Recommend plan omicron. InfoSec dept provided clj-939-v4.diff - should enable our insidious changes to slip past his Detect-O-Tron. Good luck, operative. Message ends.

Rich Hickey October 25, 2013 at 1:06 PM

this (surreptitiously? adds a new test for vector or list. Please submit patches that address one specific issue. There's no reason for this concrete check, but if you think there is make another ticket.

Completed

Details

Assignee

Reporter

Labels

Approval

Ok

Patch

Code

Priority

Fix versions

Created February 24, 2012 at 6:01 PM
Updated November 23, 2013 at 1:06 AM
Resolved November 23, 2013 at 1:06 AM