RESOLVED INVALID 138857
Updating a non-writable property of a coerced primitive object does not throw a TypeError exception in a strict mode
https://bugs.webkit.org/show_bug.cgi?id=138857
Summary Updating a non-writable property of a coerced primitive object does not throw...
Daejun Park
Reported 2014-11-18 18:50:23 PST
In a strict mode, it should throw a TypeError exception, when attempting to update a non-writable property of a coerced primitive object, but Safari does not. According to ES5, Section 8.7.2 PutValue (V, W), [[Put]] internal method, Step 2.a, http://es5.github.io/#x8.7.2 the following code is supposed to throw a TypeError exception, since "x" is not writable in the coerced number object for "1": "use strict"; Object.defineProperty(Number.prototype, "x", { "value" : 0, "writable" : false, "enumerable" : true, "configurable" : true }); 1["x"] = 10; // TypeError However, Safari does not report any exception, while Firefox correctly throws a TypeError exception. I've tested this using the Web Inspector console of Safari 7.0.4. Thanks, Daejun
Attachments
Daejun Park
Comment 1 2014-11-19 10:06:57 PST
I'm sorry for the noise. It turns out that I've missed how Web Inspector works. The above example works correctly when I wrapped the code with a function, ensuring the strict mode, as follows: function f() { "use strict"; Object.defineProperty(Number.prototype, "x", { "value" : 0, "writable" : false, "enumerable" : true, "configurable" : true }); 1["x"] = 10; // TypeError } f(); I close this issue. Thanks, Daejun
Note You need to log in before you can comment on or make changes to this bug.