bugKawa - Bugs: bug #31355, warn-access-unknown-field

 
 

bug #31355: warn-access-unknown-field

Submitter:  Helmut Eller <ellerh>
Submitted:  Sun 17 Oct 2010 07:03:52 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  Feature Request Status:  Fixed
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 26 Oct 2010 06:38:17 AM UTC, comment #4: 

"I think an full error is a too much in this case."
Note that it was an error in the "normal" case, even before my fix.  But you may be right.

I agree that taking instance? and similar tests into account when checking for type errors would be highly desirable - some Scheme type-checkers do this.  I think this makes sense as part of SSA analysis, which is one my wish-list.

For Kawa 1.11 I'm leaning towards adding a --warn-unknown-member option, and make missing field warning/errors be triggered by that warning.

Per Bothner <bothner>
Group administrator
Thu 21 Oct 2010 09:33:06 AM UTC, comment #3: 

I think an full error is a too much in this case.
If the probability for false positives is small
enough than it would be good to warn about it by default.
But I think the probability is quite high.
Consider code like:

(define (foo (l <list>))
  (cond ((instance? l <pair>)
         (let ((p :: pair l))
           (list (field p 'car)
                 (field l 'car))))
        (#t #f)))

Kawa only warns when accessing l.  It could also warn on p because the
gnu.lists.Pair class has no public field car (only a getCar method).
Under a more liberal interpretation both warnings are false positives,
because the type test guarantees that the getCar method will be found
at runtime.

I think it shouldn't even be a full warning only
an efficiency note.


Helmut Eller <ellerh>
Thu 21 Oct 2010 06:13:55 AM UTC, comment #2: 

The problem was that <list> is a special kind of type - a LangObjType rather than a regular ClassType, and the code didn't handle LangObjType as it should.  I checked in a fix for this.
We now get:
/tmp/sl.scm:2:3: no slot `car' in list

Which catches an error - the specification should be <pair>, not <list>.

It would probably make sense to have this be controlled by an option, perhaps --warn-unknown-member.  Probably the default should be on.  Should it be an error by default?  This shoudl be re-considered, next release.

Per Bothner <bothner>
Group administrator
Sun 17 Oct 2010 07:07:33 AM UTC, comment #1: 

With corrected markup:

For code like this


(define (foo (p <list>))
  (field p 'car))


Kawa falls back to reflection but doesn't warn about it
even when compiled with --warn-invoke-unknown-method.
It would be nice if it did.

Helmut Eller <ellerh>
Sun 17 Oct 2010 07:03:52 AM UTC, original submission:  

For code like this


(define (foo (p <list>))
  (field p 'car))
+verbatim+

Kawa falls back to reflection but doesn't warn about it
even when compiled with --warn-invoke-unknown-method.
It would be nice if it did.

Helmut Eller <ellerh>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-07-19 bothner Open/ClosedOpen Closed
    2010-10-21 bothner StatusNone Fixed
        Assigned toNone bothner

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code