Bug 136445
| Summary: | Assignment to a property on a primitive in strict mode should not throw | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Jordan Harband <ljharb> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED INVALID | ||
| Severity: | Normal | CC: | ggaren, mathias, oliver |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Jordan Harband
`(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; }())
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Jordan Harband
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