Closed
Bug 208496
Opened 23 years ago
Closed 23 years ago
Incorrect scope when |with (f)| is used inside the definition of |function f()|
Categories
(Core :: JavaScript Engine, defect, P2)
Tracking
()
VERIFIED
FIXED
mozilla1.5alpha
People
(Reporter: pschwartau, Assigned: brendan)
Details
(Keywords: js1.5)
Attachments
(1 file)
|
3.17 KB,
patch
|
rogerl
:
review+
|
Details | Diff | Splinter Review |
Reported by Itaj Sherman in the Mozilla JS Engine newsgroup:
----
... there is another incompatibility there (with ECMA and IE):
function MyFunc(par)
{
var a = par;
with(MyFunc)
{
var b = par;
}
}
In IE both |a| and |b| get the value the actual passed argument.
With SpiderMonkey of Mozilla 1.31, |b| will be undefined, because the
lookup finds 'par' on |MyFunc| which is the first on the scope chain,
and then getProperty is activated on |MyFunc|, using js_GetArgument().
----
| Reporter | ||
Comment 1•23 years ago
|
||
Testcase added to JS testsuite:
mozilla/js/tests/js1_5/Scope/regress-208496.js
Currently passing in Rhino; failing in SpiderMonkey.
| Assignee | ||
Comment 2•23 years ago
|
||
Patch in a second.
/be
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → mozilla1.5alpha
| Assignee | ||
Comment 3•23 years ago
|
||
I'm not going to rip out the reflection of args and local vars as properties of
their function object -- that's too big an incompatibility, and too big a
change. It could easily increase code footprint, even though we could do
without hacks such as this one. And it would increase data footprint for sure,
because it would require adding a separate, secondary scope (or equivalent) per
function, used only by the compiler.
/be
| Assignee | ||
Updated•23 years ago
|
Attachment #125112 -
Flags: review?(rogerl)
Comment 4•23 years ago
|
||
Comment on attachment 125112 [details] [diff] [review]
ad-hoc fix, ugly but small
Just for my edification; the change in jsinterp.c is an optimization because
argv is NULL so the error handling in JS_InstanceOf isn't going to be used?
(But why not the same change on line 484?)
Attachment #125112 -
Flags: review?(rogerl) → review+
| Assignee | ||
Comment 5•23 years ago
|
||
Rogerl: oops, missed that one -- I was not vigilant enough in hunting down
JS_InstanceOf(..., NULL) uses inside the engine. Now that I've expanded and
reduced the one you pointed out, only the jsfile.c one is left -- and jsfile.c
is orphaned code. Thanks, checking in.
/be
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
| Reporter | ||
Comment 6•23 years ago
|
||
We now have two regression tests for this bug:
mozilla/js/tests/js1_5/Scope/regress-208496-001.js
mozilla/js/tests/js1_5/Scope/regress-208496-002.js
I renamed mozilla/js/tests/js1_5/Scope/regress-208496.js
as regress-208496-001.js, and added regress-208496-002.
The new test, again from Itaj, checks access of static
properties of |f| from inside the |with(f)| block.
Both tests are passing in the current JS shell, and I see
no test regressions when running the JS testsuite on Linux.
Therefore marking Verified FIXED -
Status: RESOLVED → VERIFIED
Updated•21 years ago
|
Flags: testcase+
You need to log in
before you can comment on or make changes to this bug.
Description
•