Bug 138857
Summary: | Updating a non-writable property of a coerced primitive object does not throw a TypeError exception in a strict mode | ||
---|---|---|---|
Product: | WebKit | Reporter: | Daejun Park <daejunpark> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | Normal | CC: | ggaren, oliver |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Mac (Intel) | ||
OS: | OS X 10.9 |
Daejun Park
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Daejun Park
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