Closed
Bug 514564
Opened 17 years ago
Closed 17 years ago
ES5 strict mode: binding of 'arguments' is immutable
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 514562
People
(Reporter: jimb, Unassigned)
References
Details
From Annex C:
For strict mode functions, if an arguments object is created the binding of the local identifier arguments to the arguments object is immutable and hence may not be the target of an assignment expression. (10.5).
| Reporter | ||
Comment 1•17 years ago
|
||
Posted to es5-discuss:
----
Isn't it statically decidable whether or not a given assignment or post/pre inc/dec in strict mode code refers to "arguments"? That is, strict mode code may not have parameters, variables, or functions named "arguments", so strict mode functions should always have an "arguments" binding created by step 8b of the anonymous algorithm in 10.5. Thus, any time the identifier "arguments" appears in function code as the target of an assignment (etc.), you know that assignment will never succeed.
If so, it's odd that such assignments to "arguments" evoke a TypeError at assignment time, instead of being syntax errors.
This is akin to the way "delete var" is forbidden in strict mode code by having the evaluation raise a SyntaxError, instead of placing a restriction on the actual grammar, so that the issue can be raised at compile-time.
It's unfortunate. I think ES5 users would be best served if implementors ignore the letter of the law here and treat these as static restrictions, not run-time errors.
----
To put this in concrete terms, I read the spec to require that:
function f(b) { "use strict"; if (b) arguments=1; }
f(false);
run without an error, which seems silly, and contrary to the intent of strict mode.
----
For the time being I've got this as a static error. If need be, we can emit code to make things behave as I describe.
Comment 2•17 years ago
|
||
SyntaxError is what we agreed to at the May TC39 meeting -- I didn't check that the edit to the draft matched, sorry. Let's stick with it and I'll make sure the erratum is noted.
/be
| Reporter | ||
Comment 3•17 years ago
|
||
This and bug 514562 can be easily addressed at the same time.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•