> Your patch does fix the problem in Timothy's first post in that thread,
> though.
Not fully... it can still be defeated by:
(let [l nil]
(.accept l)
What I found when examining this previously was that the exception is
thrown from Relfector.java
Which is invoked from Complier.java:
FnExpr fexpr = (FnExpr) analyze(C.EXPRESSION, RT.list(FN,
PersistentVector.EMPTY, form), "eval");
IFn fn = (IFn) fexpr.eval();
return fn.invoke();
This is caught like so:
throw new CompilerException((String) SOURCE.get(), (Integer) LINE.get
(), e);
However LINE is not set in this context! (And still isn't after your
patch)
What I found is that I could use the form line instead, and that would
give a better result but would return the line number of the let form
which is misleading because the error really didn't occur on that
line.
Now that doesn't sound like a problem, so long as you can find a way
to attach LINE, however when I tried to do this I discovered that the
NPE is not found in analyze (and can't be because it would require an
eval), and that it can only be discovered by calling eval on the let
(which is obvious in hindsight from the stack trace):
at clojure.core$eval__2707.invoke(test1.clj:2)
What is really interesting here is that the line number reported in
the "Caused by" stack trace is correct.
But this exception that gets passed up is somehow not a
CompilerException so the catch clause wraps it up in a
CompilerException with line 0 (because LINE is not set).
Resulting in:
Exception in thread "main" java.lang.NullPointerException (test1.clj:
0)
at clojure.lang.Compiler.eval(Compiler.java:4127)
at clojure.lang.Compiler.load(Compiler.java:4443)
at clojure.lang.Compiler.loadFile(Compiler.java:4410)
at clojure.lang.Script.main(Script.java:65)
Caused by: java.lang.NullPointerException
at clojure.lang.Reflector.invokeNoArgInstanceMember
(Reflector.java:253)
at clojure.core$eval__2707.invoke(test1.clj:2)
at clojure.lang.Compiler.eval(Compiler.java:4116)
... 3 more
And that's where I got stuck. If anyone can see what I'm missing
please speak up :)
Also it would be really great to know the actual symbol (which I'm
sure is available if line is available).
Regards,
Tim.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---