Closed
Bug 6704
Opened 26 years ago
Closed 25 years ago
Rhino: Script exec() should use enclosing scope?
Categories
(Rhino Graveyard :: Core, defect, P3)
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.
Reporter | ||
Updated•26 years ago
|
Assignee: norris → rogerl
QA Contact: 4078 → 4590
Reporter | ||
Comment 1•26 years ago
|
||
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.
Assignee | ||
Updated•26 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 2•26 years ago
|
||
Fixed.
Assignee | ||
Updated•26 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
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)
Updated•26 years ago
|
Target Milestone: M7 → M8
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 :-)
Assignee | ||
Updated•26 years ago
|
Status: REOPENED → ASSIGNED
Assignee | ||
Comment 6•26 years ago
|
||
'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.
Updated•26 years ago
|
Target Milestone: M8 → M15
Reporter | ||
Comment 7•25 years ago
|
||
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.
Reporter | ||
Comment 8•25 years ago
|
||
Moving Rhino bugs to new Rhino product.
Assignee | ||
Updated•25 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 26 years ago → 25 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 9•25 years ago
|
||
Fixed.
You need to log in
before you can comment on or make changes to this bug.
Description
•