Closed
Bug 20256
Opened 25 years ago
Closed 25 years ago
Testcase ecma/ExecutionContexts/10.1.3.js fails
Categories
(Core :: JavaScript Engine, defect, P3)
Tracking
()
VERIFIED
FIXED
People
(Reporter: rginda, Assigned: brendan)
Details
Attachments
(4 files)
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
Details | Diff | Splinter Review |
This code is enough to demonstrate the problem:
function bogus()
{
eval("function t() {};");
eval("var t; print('t1: ' + typeof(t)); " +
"function t() { }; " +
"print('t2: ' + typeof(t)); " +
"typeof(t)");
}
bogus();
The actual testcase only checks to see that t2 is "function", and does
not care about t1. It may be interesting to note that if these eval()s
happen in different functions, the failure does not occur.
Assignee | ||
Updated•25 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 1•25 years ago
|
||
Assignee | ||
Comment 2•25 years ago
|
||
rogerl, shaver: Buddy my change!
waldemar: should the first print show 't1: undefined' or 't1: function'? My
reading of the (somewhat mangled) http://www.mozilla.org/js/language/ecma3a.html
version of the spec leaves me thinking undefined is correct. Am I missing
anything?
/be
Assignee | ||
Comment 3•25 years ago
|
||
Also, anyone know why ECMA says that "variable instantiation" in "eval code"
uses property attributes {}, while other types of code specify {DontDelete}?
/be
Assignee | ||
Comment 4•25 years ago
|
||
Assignee | ||
Comment 5•25 years ago
|
||
That last patch avoids breaking compatibility with Math.eval("sin(x)*cos(y)...")
without requiring Call objects to be exposed as this parameters. No change to
jsconfig.h required, so revert that file to trunk revision if you applied the
first patch.
/be
Assignee | ||
Comment 6•25 years ago
|
||
Assignee | ||
Comment 7•25 years ago
|
||
The jsobj.c re-patch defends against null caller->pc.
The jsparse.c patch detects when the compiler is called (via eval or
Script.compile) from within a with statement. With this patch, whereever you
find InWithStatement called in jsparse.c to see whether the code being parsed is
within a with statement also being parsed by the same parser invocation, there
is also a (prior, because faster) disjunctive test of cx->fp->scopeChain != obj
(or == obj followed by && !InWithStatement(tc)), where obj is the ECMA Variable
object found by js_FindVariableScope.
The jsparse.c patch fixes this case:
js> version(120)
js> function f(o,s){var x=44;var y=o.eval(s);return y}
js> o42={x:42}
js> f(o42,"x+1")
43
js> f(o42, "var x=1")
2
js> o42.x
1
I'm still looking for a definitive ruling, but I think ECMA says that var in a
with statement in a function does create a local variable, but if initialized,
may not set that local variable if the with object contains a property of the
same name as the variable -- that property would be set instead:
js> function f(o){with(o) var x=1; return x}
js> o42={x:42}
js> f(o42)
undefined
js> o42.x
1
Someone holler if I'm misinterpreting ECMA.
Anyone have on the cc: list, please review these and mail me or update the bug
saying whether these changes look good.
/be
Assignee | ||
Comment 8•25 years ago
|
||
Assignee | ||
Updated•25 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 9•25 years ago
|
||
rginda tested, i checked in. Thanks to rob -- verify me!
/be
Reporter | ||
Updated•25 years ago
|
Status: RESOLVED → VERIFIED
Reporter | ||
Comment 10•25 years ago
|
||
looks good from here.
Comment 11•25 years ago
|
||
I agree that Brendan's interpretation of the interaction of var and with matches
the current ECMA spec.
You need to log in
before you can comment on or make changes to this bug.
Description
•