Closed
Bug 184107
Opened 22 years ago
Closed 22 years ago
with(...) { function f ...} should set f in the global scope
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
VERIFIED
FIXED
1.5R4
People
(Reporter: user, Assigned: norrisboyd)
Details
Attachments
(1 file)
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003
When evaluationg the following test:
var x = {y:10};
with (x) {
function f() {
return y;
}
}
var result = f();
var ok1 = (x.f === undefined)
print(ok1)
var ok2 = (result === x.y);
print(ok2)
Rhino incorrectly put f into the x object instead of the global scope.
The test would work as expected if function f()... would be replaced by f =
function()...
Reproducible: Always
Steps to Reproduce:
Comment 1•22 years ago
|
||
Testcase added to JS testsuite:
mozilla/js/tests/js1_5/Scope/regress-184107.js
Currently passing in SpiderMonkey. In Rhino, the test fails in both
compiled and interpreted modes. As Igor states, function expressions
f = function()...
are correctly created by Rhino in global scope, but function statements
function f() ...
are being created in local scope.
Summary: with(...) { function f ...} should set f in the global scope → with(...) { function f ...} should set f in the global scope
Reporter | ||
Comment 2•22 years ago
|
||
After the patch js1_5/Scope/regress-185485.js will fail as the patch follows SM
path there and SM copes with this Ecma extension in a different way as Netscape
4.* and it was decided that it was OK to keep the current SM behavior in this
obscure case.
Reporter | ||
Comment 3•22 years ago
|
||
I commited the fix.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Comment 4•22 years ago
|
||
Verified FIXED.
The above testcase, js1_5/Scope/regress-184107.js, now passes in
both Rhino interpreted and comiled modes.
The testcase js1_5/Scope/regress-185485.js has now been corrected.
It now passes in Rhino as well as in SpiderMonkey -
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•