bugKawa - Bugs: bug #32999, Eval doesn't resolve symbols when...

 
 

bug #32999: Eval doesn't resolve symbols when compiled

Submitted by:  None
Submitted on:  Tue 05 Apr 2011 07:55:00 AM UTC  
 
Category: Code generationSeverity: 3 - Normal
Item Group: Run-time exceptionStatus: Invalid
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.

 

Tue 05 Apr 2011 03:49:03 PM UTC, comment #1:

This behavior is intentional. The body of the eval is in a different "module" than the tst.scm file. Therefore the former can't see the latter. This behavior is desirable for modularity and performance (since it enables better optimizations by the compiler).

You can get the behavior you want by replacing 'define' with 'define-variable'. That declares func to be a "dynamic" variable.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Tue 05 Apr 2011 07:55:00 AM UTC, original submission:

There appears to be an issue with symbol resolution when using eval with compiled code.

Test case:

(define func (lambda (x) (+ x 5)))

((eval (string->symbol "func")) 5) ; Expected result 10

The above code, when run through the kawa interpreter, correctly returns 10. When compiled with

kawa --main --module-static -C tst.scm

where tst.scm contains the above test, the resulting class produces:

unbound location func
at gnu.mapping.Location.get(Location.java:67)
at atEvalLevel$1.run(<eval>)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:286)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:187)
at kawa.lang.Eval.evalBody(Eval.java:103)
at kawa.lang.Eval.eval(Eval.java:31)
at kawa.lang.Eval.eval(Eval.java:59)
at kawa.lang.Eval.apply1(Eval.java:118)
at tst.run(tst.scm:3)
at gnu.expr.ModuleBody.run(ModuleBody.java:44)
at gnu.expr.ModuleBody.run(ModuleBody.java:32)
at gnu.expr.ModuleBody.runAsMain(ModuleBody.java:145)
at tst.main(tst.scm)

The above test case was tested against trunk on 5 Apr 2011

Anonymous

 

(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)
  •  

    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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 01 May 2011 04:50:52 PM UTCbothnerOpen/ClosedOpen=>Closed
    Tue 05 Apr 2011 03:49:03 PM UTCbothnerStatusNone=>Invalid
      Assigned toNone=>bothner

    Back to the top


    Powered by Savane 3.1-cleanup1