Sun 29 Apr 2012 11:17:42 AM UTC, original submission:
The following should output a syntax error rather than a NPE:
#|kawa:1|# (zero? (define-simple-class))
java.lang.NullPointerException
at kawa.standard.define_class.rewriteForm(define_class.java:122)
...
Jamison investigated this on the mailing lists:
"The cause is that define_class#rewriteForm() does this:
Declaration decl = null;
Object form_cdr = form.getCdr(); // form is the list (define-simple-class), so form_cdr is ()
if (form_cdr instanceof Pair) // and () is not a pair, so we skip directly to line 122
{
...
}
ClassExp oexp = (ClassExp) decl.getValue(); // here, where decl is still null, triggering the NPE
So that if statement should probably have an else clause, something like
else
{
return tr.syntaxError(this.getName() + ": missing class name");
}
or maybe "else if (form_cdr == EmptyList.emptyList) { ... } else {...}"
so other bad syntax like "(define-simple-class . 42)" can have a different
error message."
Just needs to be patched. I'll do this eventually, putting it on Savannah so that it's not forgotten.
|