Closed
Bug 530650
Opened 16 years ago
Closed 13 years ago
Local functions named 'arguments' should override the arguments object
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
DUPLICATE
of bug 740446
Tracking | Status | |
---|---|---|
blocking2.0 | --- | - |
People
(Reporter: jimb, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: regression, Whiteboard: softblocker)
Attachments
(3 obsolete files)
At the moment, SpiderMonkey allows the arguments object to override local functions named 'arguments'.
js> function f() { function arguments() { return 42; }; return arguments; }
js> f(1,2,3).length
3
However, this is contrary to what both ECMA 3 and ECMA 5 (with pending correction) specify.
(For the pending ECMA 5 correction, see: https://mail.mozilla.org/pipermail/es5-discuss/2009-November/003435.html)
Reporter | ||
Comment 1•16 years ago
|
||
Reporter | ||
Comment 2•16 years ago
|
||
Brendan says this is a "regression from 3.0 for sure (just tested with cvs.m.o js shell).
Comment 3•16 years ago
|
||
cvs.m.o js shell:
js> dis(f)
main:
00000: deflocalfun 0 null
00005: nop
00006: getvar 0
00009: return
00010: stop
Source notes:
0: 5 [ 5] funcdef function 0 (function arguments() {return 42;})
hg.m.o m-c js shell:
main:
00000: trace
00001: deflocalfun 0 function arguments() {return 42;}
00006: nop
00007: arguments
00008: return
00009: stop
Where'd that arguments (JSOP_ARGUMENTS) come from? Sigh, upvar2 damage.
/be
Assignee: general → brendan
Blocks: upvar2
Status: NEW → ASSIGNED
Flags: in-testsuite?
Flags: blocking1.9.2?
Keywords: regression
Comment 4•16 years ago
|
||
Given the late date, and given that anyone who names a function "arguments" deserves worse than a wrong value when trying to use the name "arguments", I don't think this should block.
Reporter | ||
Comment 5•16 years ago
|
||
(In reply to comment #3)
> Where'd that arguments (JSOP_ARGUMENTS) come from? Sigh, upvar2 damage.
Indeed:
+ hg bisect --bad
The first bad revision is:
changeset: 26784:2cf0bbe3772a
user: Brendan Eich <brendan@mozilla.org>
date: Sun Apr 05 21:17:22 2009 -0700
summary: upvar2, aka the big one take 2 (452598, r=mrbkap).
Comment 6•16 years ago
|
||
The blocking status depends on risk analysis, not attitude. People do lots of silly things in Web JS, including in sites and web apps we can't afford to break. So please add light not heat when commenting on blocking.
That said, we don't have reports of breakage from users of 3.5.x and 3.6 betas. If I can get a small patch, I'll settle for wanted1.9.2 and get it in that way. The important thing is to get a safe fix.
/be
Comment 7•16 years ago
|
||
Eep. The code to eagerly bind JSOP_ARGUMENTS is just wrong:
js> function f(x){ return let (arguments = x) arguments; }
js> f(42).length
1
Not that anyone uses let to bind a block-local named arguments!
/be
Comment 8•16 years ago
|
||
I agree with Brendan's analysis in comment 6; should fix, would take a safe patch definitely, doesn't block release since we haven't seen a lot of site bustage from this in Firefox 3.5 yet.
Flags: wanted1.9.2+
Flags: blocking1.9.2?
Flags: blocking1.9.2-
Comment 9•16 years ago
|
||
Which I guess means we all agree. :-)
Comment 10•16 years ago
|
||
As discussed, slots[0] is fought over with loser suffering bugs, between first local var and arguments object. But this is close. Maybe use slots[nfixed-1]? Or something...
/be
Updated•16 years ago
|
Assignee: brendan → lw
![]() |
||
Comment 11•15 years ago
|
||
Oops, didn't realize this was still assigned to me. For a while, I was interested in the 'this function uses the arguments object' compiler analysis part of the patch (for bug 539144), but I ended up not needing it.
Assignee: lw → general
Comment 12•15 years ago
|
||
The bug number in changeset 2cf0bbe3772a seems to be wrong. Anyone know what the correct one is?
Thanks,
Dave
Comment 13•15 years ago
|
||
Ah, bug 452498. For reference, changeset 2cf0bbe3772a (mozilla-central, forgot to specify) is at:
http://hg.mozilla.org/mozilla-central/rev/2cf0bbe3772a
Dave
Comment 14•15 years ago
|
||
I had to set the overrides-args bit in jsinterp and the method-JIT. (I'm not sure I did it right in the latter). Brendan tells me that ideally we should be able to exploit the CallPropertyOp path that sets the bit, so hopefully we can eliminate the added fun->atom == cx->runtime->atomState.argumentsAtom tests.
Dave
Assignee: general → dherman
Comment 15•15 years ago
|
||
FYI: just filed bug 604251 for similar issues of shadowed 'arguments' but with block-scoping.
Dave
Comment 16•15 years ago
|
||
(In reply to comment #14)
> wip; dynamically sets the arg-override bit
HM, I do not see why we should set anything dynamically here. It seems a bytecode like JSOP_CALLARGUMENTS should solve the issue here.
Updated•15 years ago
|
blocking2.0: --- → ?
OS: Linux → All
Hardware: x86 → All
Comment 17•15 years ago
|
||
Igor, can you take this bug off dherman's hands? Or let me know if not and I'll try to get to it. Your suggestion in comment 16 sounds good.
/be
Updated•15 years ago
|
blocking2.0: ? → betaN+
Updated•15 years ago
|
Assignee: dherman → igor
Updated•15 years ago
|
Whiteboard: softblocker
Comment 18•15 years ago
|
||
** PRODUCT DRIVERS PLEASE NOTE **
This bug is one of 19 being moved from blocking2.0:betaN+ to blocking2.0:- as we reached the endgame of Firefox 4. The rationale for the move is:
- the bug had been identified as a "soft" blocker which could be fixed in some follow up release
- the bug had been identified as one requiring beta coverage, thus is not appropriate for a ".x" stability & security release
The owner of the bug may wish to renominate for .x consideration.
blocking2.0: betaN+ → .x+
Comment 20•14 years ago
|
||
S10.1.3_A4_T1 in test262 checks for absence of this bug, amongst other semantics. Anyone object overmuch if I pick up the patch here and do what needs doing to land it, or want to do that work themselves?
Reporter | ||
Comment 21•14 years ago
|
||
No objections from me.
Comment 22•14 years ago
|
||
Have at it!
Thanks,
Dave
Updated•14 years ago
|
Comment 23•14 years ago
|
||
Jeff, did you mean to assign this to yourself?
Updated•14 years ago
|
Assignee: igor → general
Comment 24•14 years ago
|
||
Probably. But I also don't really have time for this right now, alas, due to bug 586842. Hopefully I can swing back semi-shortly after that's done. If anyone wants to steal this in the meantime, go ahead.
![]() |
||
Comment 25•13 years ago
|
||
With great unhackage comes great dup'ing.
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
![]() |
||
Comment 27•13 years ago
|
||
Comment on attachment 414108 [details] [diff] [review]
Test that local functions named 'arguments' shadow arguments object.
Obsoleted by dupe.
Attachment #414108 -
Attachment is obsolete: true
![]() |
||
Comment 28•13 years ago
|
||
Comment on attachment 421182 [details] [diff] [review]
patch in progress
Obsoleted by dupe.
Attachment #421182 -
Attachment is obsolete: true
![]() |
||
Comment 29•13 years ago
|
||
Comment on attachment 483000 [details] [diff] [review]
wip; dynamically sets the arg-override bit
Obsoleted by dupe.
Attachment #483000 -
Attachment is obsolete: true
You need to log in
before you can comment on or make changes to this bug.
Description
•