Bug 48632
Summary: | ES5 Strict mode: Assignment to readonly custom properties should throw a TypeError | ||
---|---|---|---|
Product: | WebKit | Reporter: | Asen Bozhilov <asen.bozhilov> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED WORKSFORME | ||
Severity: | Normal | CC: | barraclough, erights, oliver |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | PC | ||
OS: | Linux |
Asen Bozhilov
The follow test case has been used:
/**
* 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
* {[[Set]]: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).
*/
var testDesc = 'Assignment to property with [[Writable]] false must produce a TypeError: ';
try {
eval('"use strict"; (function(){}).length = 20;');
util.printLine(testDesc + 'FALSE');
} catch (e) {
if (e instanceof TypeError) {
util.printLine(testDesc + 'TRUE');
}
else {
util.printLine(testDesc + 'UNDEFINED BEHAVIOR');
}
}
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Oliver Hunt
This a problem specific to function.length and other similar properties that use magic logic to determine their actual value.
Gavin Barraclough
Function/Array/Arguments/String/RegExp all look like they should work correctly. If there are any custom read-only properties I've missed that don't throw, please reopen.
cheers, G.