Bug 136445 - Assignment to a property on a primitive in strict mode should not throw
Summary: Assignment to a property on a primitive in strict mode should not throw
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-01 23:33 PDT by Jordan Harband
Modified: 2014-09-02 19:40 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 Jordan Harband 2014-09-01 23:33:13 PDT
`(function () { "use strict"; 3.0.a = true; }())`
`(function () { "use strict"; 'foo'.a = true; }())`
`(function () { "use strict"; true.a = true; }())`

None of these throw exceptions in Chrome, Firefox, Opera - but in Safari 7.1, these all throw a TypeError "Attempted to assign to readonly property.".

According to the ES5 spec ( https://es5.github.io/#C ) and ES6 spec ( https://people.mozilla.org/~jorendorff/es6-draft.html#sec-strict-mode-of-ecmascript ), Safari is in error here. In addition, one of the TC39 spec maintainers confirmed via Twitter that this is a Safari bug ( https://twitter.com/awbjs/status/506687103506587648 )

Steps to Reproduce:
Run any of the JS functions in the console, or any other JS mechanism:

(function () { "use strict"; 3.0.a = true; }())

(function () { "use strict"; 'foo'.a = true; }())

(function () { "use strict"; true.a = true; }())
Comment 1 Jordan Harband 2014-09-02 10:10:41 PDT
Sorry for the noise - turns out Safari is the only browser doing this correctly. https://twitter.com/awbjs/status/506845194025594881

https://code.google.com/p/v8/issues/detail?id=3088 and https://bugzilla.mozilla.org/show_bug.cgi?id=779682