Bug 138858
| Summary: | Updating an immutable binding does not throw a TypeError exception in a strict mode | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Daejun Park <daejunpark> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | ggaren, oliver, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| 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 an immutable binding, but Safari does not.
According to ES5, Section 10.2.1.1.3 SetMutableBinding (N,V,S), Step 4,
http://es5.github.io/#x10.2.1.1.3
the following code is supposed to throw a TypeError exception, since "g" is an immutable binding inside the function body (according to ES5, Section 13 Function Definition, Step 3 of the third block).
"use strict";
var f = function g() {
g = 0;
};
f(); // 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
For your information, this issue appears even if I wrapped the code as follows:
function x() {
"use strict";
var f = function g() {
g = 0;
};
f(); // TypeError
}
x();
Also, I reported this issue for v8:
https://code.google.com/p/v8/issues/detail?id=3704
but it turns out that it was duplicate:
https://code.google.com/p/v8/issues/detail?id=2243
and it will not be fixed because ES6 will consider this as a syntax error.
Do you have the same decision for this?
Radar WebKit Bug Importer
<rdar://problem/19032831>