WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
138859
global function declaration should be throwing a TypeError if trying to override a readonly property
https://bugs.webkit.org/show_bug.cgi?id=138859
Summary
global function declaration should be throwing a TypeError if trying to overr...
Daejun Park
Reported
2014-11-18 19:10:45 PST
According to ES5, Section 10.5 Declaration Binding Instantiation, Step 5.e.iv,
http://es5.github.io/#x10.5
a duplicate global function declaration throws a TypeError exception, when the existing property is not configurable and: - an accessor descriptor, - or, not writable, - or, not enumerable. For example, the following code is supposed to throw a TypeError exception for each duplicate function declaration, "f0", "f1", "f2", and "f3": Object.defineProperty(this, "f0", { "get" : undefined, "set" : undefined, "enumerable" : false, "configurable" : false }); eval(" function f0() { return 0; } "); // TypeError Object.defineProperty(this, "f1", { "value" : 0, "writable" : false, "enumerable" : false, "configurable" : false }); eval(" function f1() { return 0; } "); // TypeError Object.defineProperty(this, "f2", { "value" : 0, "writable" : true, "enumerable" : false, "configurable" : false }); eval(" function f2() { return 0; } "); // TypeError Object.defineProperty(this, "f3", { "value" : 0, "writable" : false, "enumerable" : true, "configurable" : false }); eval(" function f3() { return 0; } "); // TypeError However, Safari does not report any exception, while Chrome and Firefox correctly throw the TypeError exceptions. I've tested this using the Web Inspector console of Safari 7.0.4. Thanks, Daejun
Attachments
Add attachment
proposed patch, testcase, etc.
Oliver Hunt
Comment 1
2014-11-19 08:51:54 PST
Retitling to reflect actual bug - it's not due to a duplicate function. We're short circuiting creation of a new global property when we decide to shadow and that means we skip the readonly check on the existing property. Whoops.
Radar WebKit Bug Importer
Comment 2
2014-11-19 11:17:52 PST
<
rdar://problem/19032865
>
Satish Srinivasan
Comment 3
2025-12-02 23:33:44 PST
I think this is already fixed in 355e9d25900a300375b1b68576f926278d8b5903. JavaScriptCore from Safari Version 26.1 (21622.2.11.11.9) does throw TypeError for all four cases.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug