bugKawa - Bugs: bug #32294, Environment.setIndirectDefines...

 
 

bug #32294: Environment.setIndirectDefines broken

Submitter:  tk <huh>
Submitted:  Sat 29 Jan 2011 09:03:46 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  Run-time exception Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 16 May 2011 03:51:00 PM UTC, comment #2: 

i'm cleaning up some of my local kawa hacks and noticed that
this fix has not gotten into the source trunk. does this need
a proper patch diff + changelog entry, or is there another
reason not to incorporate it?
thanks...

tk <huh>
Tue 01 Feb 2011 06:40:20 AM UTC, comment #1: 

The patch is probably ok, since it just comments out an optimization.  I don't have a good feeling for how much difference the optimization makes.  It seems like it should be possible to replace the optimization by one defer the optimization to lookupInherited: If the appropriate flags are set then we cam skip the lookup in the parent.

Per Bothner <bothner>
Group administrator
Sat 29 Jan 2011 09:03:46 PM UTC, original submission:  

using Environment.setIndirectDefines causes subsequent defines to
throw exceptions. [1.11 (revision 6892M)]

following transcript shows simple means of reproducing lossage,
and a couple of hints (perhaps) about where things are going wrong.
(I haven't yet determined a fix that I trust).


## $ kawa --server 3333

$ rlwrap nc localhost 3333
#|kawa:1|# (interaction-environment)
#<environment r0>

#|kawa:2|# (invoke (interaction-environment) 'getParent 0)
/dev/stdin:2:1: warning - no accessible method 'getParent' in gnu.mapping.Environment
#<environment language-builtins>

#|kawa:3|# (invoke (interaction-environment) 'setIndirectDefines)

#|kawa:4|# (define x 1)
Invalid parameter, was: gnu.expr.BuiltinEnvironment cannot be cast to gnu.mapping.SimpleEnvironment
java.lang.ClassCastException: gnu.expr.BuiltinEnvironment cannot be cast to gnu.mapping.SimpleEnvironment
at gnu.mapping.SimpleEnvironment.addLocation(SimpleEnvironment.java:204)
at gnu.mapping.SimpleEnvironment.addLocation(SimpleEnvironment.java:175)
at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:329)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:188)
at kawa.Shell.run(Shell.java:284)
at kawa.Shell.run(Shell.java:197)
at kawa.Shell.run(Shell.java:178)
at kawa.TelnetRepl.apply0(TelnetRepl.java:23)
at gnu.mapping.RunnableClosure.run(RunnableClosure.java:78)
at gnu.mapping.Future.run(Future.java:44)


################

it was a little surprising that the repl's parent environment
was #<environment language-builtins> -- I'd have expected
the parent to be the TelnetRepl's environment.

I took a look at cloneForThread in gnu.mapping.Environment,
and did an experiment with commenting the following block
of code at the beginning of the method. I don't claim
that this is a fix by any means...not sure what's going
on here....but this change allows setIndirectDefines
to (appear to) work correctly


  SimpleEnvironment cloneForThread ()
  {
    InheritingEnvironment env = new InheritingEnvironment(null, this);

    // There is no point for a lookup to search this Environment,
    // since its bindings will be cloned.  Instead patch the new Environment
    // so it inherits from its grandparents instead.
    /*
    if (this instanceof InheritingEnvironment)
      {
        InheritingEnvironment p = (InheritingEnvironment) this;
        int numInherited = p.numInherited;
        env.numInherited = numInherited;
        env.inherited = new Environment[numInherited];
        for (int i = 0;  i < numInherited;  i++)
          env.inherited[i] = p.inherited[i];
      }
    */



$ rlwrap nc localhost 3333
#|kawa:1|# (interaction-environment)
#<environment r0>

#|kawa:2|# (invoke (interaction-environment) 'getParent 0)
/dev/stdin:2:1: warning - no accessible method 'getParent' in gnu.mapping.Environment
#<environment main>

#|kawa:3|# (invoke (interaction-environment) 'setIndirectDefines)

#|kawa:4|# (define x 1)


$ rlwrap nc localhost 3333
#|kawa:1|# x
1

### this is the expected result...definition of x is shared across repls

tk <huh>

 

(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 huh (Submitted the item)
  • -email is unavailable- added by huh
  •  

    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.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-01-29 huh Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code