Closed
Bug 514560
Opened 15 years ago
Closed 15 years ago
ES5 strict mode: assignments to undeclared variables not permitted
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: jimb, Assigned: jimb)
References
(Blocks 1 open bug)
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(1 file, 2 obsolete files)
From ES5 Appendix C:
Assignment to an undeclared identifier or otherwise unresolvable reference does not create a property in the global object. When a simple assignment occurs within strict mode code, its LeftHandSide must not evaluate to an unresolvable Reference. If it does a ReferenceError exception is thrown (8.7.2). The LeftHandSide also may not be a reference to a data property with the attribute value {[[Writable]]:false}, to an accessor property with the attribute value {[[Put]]:undefined}, nor to a non-existent property of an object whose [[Extensible]] internal property has the value false. In these cases a TypeError exception is thrown (11.13.1).
Assignee | ||
Comment 1•15 years ago
|
||
The 2009-9-12 errata for ES5 changes the [[Put]] in the paragraph above to [[Set]].
Assignee | ||
Comment 2•15 years ago
|
||
Attachment #404913 -
Flags: review?
Assignee | ||
Updated•15 years ago
|
Attachment #404913 -
Flags: review? → review?(jorendorff)
Comment 3•15 years ago
|
||
Comment on attachment 404913 [details] [diff] [review]
Forbid assignments to undeclared variables in strict mode code.
Looks good!
Attachment #404913 -
Flags: review?(jorendorff) → review+
Comment 4•15 years ago
|
||
Er, I mean, "This is missing tests. r=me with that fixed."
Assignee | ||
Comment 5•15 years ago
|
||
Now --- with tests! (No changes to code.)
Attachment #404913 -
Attachment is obsolete: true
Attachment #406737 -
Flags: review?(jorendorff)
Comment 6•15 years ago
|
||
So. Maybe I'm the only one, but I absolutely hate some of the testing-function gunk some of the JS tests use. Here you use "becomes" and "never" functions, which first of all I can't even find in any of the shell.js files, and second of all which don't imply obvious functionality (I don't remember ever seeing them before). At least in my mind.
Could we just make the don't-compile tests be -n tests instead, for much greater clarity?
Assignee | ||
Comment 7•15 years ago
|
||
Actually, this is an unfortunate consequence of me having split up the strict mode work amongst a bunch of different bugs. becomes, never, always, and so on are defined in that directory's shell.js, which is added here:
https://bugzilla.mozilla.org/attachment.cgi?id=406543&action=diff
Assignee | ||
Comment 8•15 years ago
|
||
In general, I think it's important to have something like 'becomes' or 'never', because the goal here is to verify that a given form is fine in loose mode, but elicits an error in strict mode. I could certainly write both halves of that out, but it's really illegible.
Please check out the shell.js and see if you can find it in your heart to forgive me a little abstraction. :)
Comment 9•15 years ago
|
||
Comment on attachment 406737 [details] [diff] [review]
Forbid assignments to undeclared variables in strict mode code.
Bug 521868 comment 3 applies here too.
Attachment #406737 -
Flags: review?(jorendorff)
Assignee | ||
Comment 10•15 years ago
|
||
Tests revised per jorendorff's and waldo's comments.
Attachment #406737 -
Attachment is obsolete: true
Assignee | ||
Comment 11•15 years ago
|
||
Status: NEW → ASSIGNED
Whiteboard: fixed-in-tracemonkey
Assignee | ||
Updated•15 years ago
|
Flags: in-testsuite+
Comment 12•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 13•15 years ago
|
||
There are four cases this bug is meant to cover:
- assignment to an undeclared idenifier
- assignment to read-only properties
- assignment to accessors lacking Put methods
- assignment to non-existent properties on non-extensible objects
The patch in this bug only addresses the first, so I'm re-opening it.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 14•15 years ago
|
||
bug 537873 covers the second and third cases.
Assignee | ||
Comment 15•15 years ago
|
||
bug 492849 covers the fourth case.
Assignee | ||
Updated•15 years ago
|
Status: REOPENED → RESOLVED
Closed: 15 years ago → 15 years ago
Resolution: --- → FIXED
![]() |
||
Updated•14 years ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•