bug-kawa
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-kawa] [bug #32294] Environment.setIndirectDefines broken


From: tk
Subject: [Bug-kawa] [bug #32294] Environment.setIndirectDefines broken
Date: Sat, 29 Jan 2011 21:03:47 +0000
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.6 Safari/534.16

URL:
  <http://savannah.gnu.org/bugs/?32294>

                 Summary: Environment.setIndirectDefines broken
                 Project: Kawa
            Submitted by: huh
            Submitted on: Sat 29 Jan 2011 09:03:46 PM GMT
                Category: None
                Severity: 3 - Normal
              Item Group: Run-time exception
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

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





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?32294>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]