Error "Can't refer to qualified var that doesn't exist" should name the bad symbol

Description

Def of var with a ns that doesn't exist will yield this error:

Cause: Compiler.lookupVar() returns null if the ns in a qualified var does not exist yet.

Proposed: The error message would be improved by naming the symbol and throwing a CompilerException with file/line/col info. It's not obvious, but this may be the only case where this error occurs. If so, the error message could be more specific that the ns is the part that doesn't exist.

Patch: clj-1400-4.diff

Screened by: Alex Miller

Environment

OS X

Activity

Show:
Scott Bale
September 12, 2014, 5:22 AM

(properly named patch)

Alex Miller
September 12, 2014, 5:37 AM

You could throw a CompilerException with the location of the problem instead (as the ticket description suggests).

Scott Bale
September 19, 2014, 8:37 PM

Sorry, I should've mentioned because this wasn't obvious to me either (and in fact I forgot until just now): the RuntimeException is already caught and wrapped in a CompilerException.

I'm not sure which try-catch block within Compiler.java this is happening in, there are multiple. But you can see in the output that the exception is a CompilerException and the file|line|col info is there:

In the Repl...

...or in a source file

Also, at the point at which the RuntimeException of this patch is being thrown, the source line and col params to CompilerException are not available, or at least not afaict.

Alex Miller
October 7, 2014, 6:34 PM

I'll follow up on this patch later - Rich thought it was making too many assumptions. I think we validated many of those but need to double-check those.

Alex Miller
November 21, 2018, 3:16 AM

Updated error result as of Clojure 1.10. It is now throwing a :compile-syntax error phase exception with file/line/col too.

Assignee

Unassigned

Reporter

Howard Lewis Ship

Labels

Approval

Vetted

Patch

Code and Test

Affects versions

Priority

Minor
Configure