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)

x86
Linux
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: rginda, Assigned: brendan)

Details

Attachments

(4 files)

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.
Status: NEW → ASSIGNED
Attached patch proposed fix (deleted) — Splinter Review
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
Also, anyone know why ECMA says that "variable instantiation" in "eval code" uses property attributes {}, while other types of code specify {DontDelete}? /be
Attached patch better proposed fix (deleted) — Splinter Review
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
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
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
rginda tested, i checked in. Thanks to rob -- verify me! /be
Status: RESOLVED → VERIFIED
looks good from here.
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.

Attachment

General

Created:
Updated:
Size: