Bug 48632 - ES5 Strict mode: Assignment to readonly custom properties should throw a TypeError
Summary: ES5 Strict mode: Assignment to readonly custom properties should throw a Type...
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-29 07:03 PDT by Asen Bozhilov
Modified: 2012-03-12 01:06 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Asen Bozhilov 2010-10-29 07:03:01 PDT
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');
    }
}
Comment 1 Oliver Hunt 2010-10-29 10:33:41 PDT
This a problem specific to function.length and other similar properties that use magic logic to determine their actual value.
Comment 2 Gavin Barraclough 2012-03-12 01:06:23 PDT
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.