Closed Bug 6704 Opened 26 years ago Closed 25 years ago

Rhino: Script exec() should use enclosing scope?

Categories

(Rhino Graveyard :: Core, defect, P3)

x86
Windows NT
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: norrisboyd, Assigned: rogerl)

Details

js> function f(x) { s.exec(); } js> var s = new Script("print(x)"); js> f(3) js: "x" is not defined.
Assignee: norris → rogerl
QA Contact: 4078 → 4590
Roger, can you take this? I think we need to do for exec what we did for eval, although it's a little more complicated since exec is a method rather than a global function.
Status: NEW → ASSIGNED
Fixed.
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
Target Milestone: M7
this is verified but i'll write a test for this.
Status: RESOLVED → REOPENED
the example above works okay. however, the following example does not: js> function f(x) { return s.exec(); } var s = new Script( "return x;"); var result = f(3); js> js: "<Script object>", line 1: invalid return js: return x; js: .....^ java.lang.NullPointerException: at org.mozilla.javascript.FunctionObject.construct (FunctionObject.java:445) at org.mozilla.javascript.ScriptRuntime.newObject (ScriptRuntime.java:1290) at c32.call(<stdin>:11) at c32.exec(<stdin>) at org.mozilla.javascript.Context.evaluateReader(Context.java:691) at org.mozilla.javascript.Context.evaluateString(Context.java:655) at org.mozilla.javascript.tools.shell.Main.processSource(Compiled Code) at org.mozilla.javascript.tools.shell.Main.main(Main.java:135)
Target Milestone: M7 → M8
Resolution: FIXED → ---
Clearing Fixed resolution since bug has been set to Reopened. If this bug is actually fixed and verified, cbegle, I will leave it up to you to mark Verified/Fixed and perhaps open a new bug for the new behavior :-)
Status: REOPENED → ASSIGNED
'var s = new Script( "return x;");' doesn't work because the script is not compiled within a function scope, even though it's going to be executed there, and so a return statement makes no sense. However, 'var s = new Script( "function y() { return x; } y(); ");' gives different answers on Rhino and Monkey. I'm going to have to ask a language lawyer to see which is right.
Target Milestone: M8 → M15
Script.exec() should *not* use the enclosing scope. Unfortunately, it currently does: js> s = new Script("print(a+1)"); function () { [native code] } js> a = 4 4 js> function f() { var a = 7 s.exec(); } js> f() 8 Calling f() should print out 5 rather than 8 on both engines.
Moving Rhino bugs to new Rhino product.
Status: ASSIGNED → RESOLVED
Closed: 26 years ago25 years ago
Resolution: --- → FIXED
Fixed.
Target Milestone: M15 → ---
Trageting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
Untargeting wrong milestone
Target Milestone: 1.5R5 → ---
You need to log in before you can comment on or make changes to this bug.