bugKawa - Bugs: bug #36335, NPE on syntax error

 
 

bug #36335: NPE on syntax error

Submitted by:  Charles Turner <charlest>
Submitted on:  Sun 29 Apr 2012 11:17:42 AM UTC  
 
Category: Scheme languageSeverity: 3 - Normal
Item Group: Compile-time exceptionStatus: Fixed
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 04 May 2012 04:57:08 AM UTC, comment #1:

I checked in a fix for this (and a few related errors),
plus a test-case. Thanks!

Per Bothner <bothner>
Project AdministratorIn charge of this item.
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.

Charles Turner <charlest>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bothner (Posted a comment)
  • -unavailable- added by charlest (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 04 May 2012 04:57:24 AM UTCbothnerOpen/ClosedOpen=>Closed
    Fri 04 May 2012 04:57:08 AM UTCbothnerItem GroupRun-time exception=>Compile-time exception
      StatusNone=>Fixed
      Assigned toNone=>bothner

    Back to the top


    Powered by Savane 3.1-cleanup1