<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>138859</bug_id>
          
          <creation_ts>2014-11-18 19:10:45 -0800</creation_ts>
          <short_desc>global function declaration should be throwing a TypeError if trying to override a readonly property</short_desc>
          <delta_ts>2025-12-02 23:33:44 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac (Intel)</rep_platform>
          <op_sys>OS X 10.9</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>EasyFix, GoodFirstBug, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Daejun Park">daejunpark</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ggaren</cc>
    
    <cc>kling</cc>
    
    <cc>msaboff</cc>
    
    <cc>oliver</cc>
    
    <cc>vasan.s</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1049698</commentid>
    <comment_count>0</comment_count>
    <who name="Daejun Park">daejunpark</who>
    <bug_when>2014-11-18 19:10:45 -0800</bug_when>
    <thetext>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, &quot;f0&quot;, &quot;f1&quot;, &quot;f2&quot;, and &quot;f3&quot;:

Object.defineProperty(this, &quot;f0&quot;, { &quot;get&quot; : undefined, &quot;set&quot; : undefined, &quot;enumerable&quot; : false, &quot;configurable&quot; : false });
eval(&quot; function f0() { return 0; } &quot;); // TypeError

Object.defineProperty(this, &quot;f1&quot;, { &quot;value&quot; : 0,      &quot;writable&quot; : false, &quot;enumerable&quot; : false, &quot;configurable&quot; : false });
eval(&quot; function f1() { return 0; } &quot;); // TypeError

Object.defineProperty(this, &quot;f2&quot;, { &quot;value&quot; : 0,      &quot;writable&quot; : true,  &quot;enumerable&quot; : false, &quot;configurable&quot; : false });
eval(&quot; function f2() { return 0; } &quot;); // TypeError

Object.defineProperty(this, &quot;f3&quot;, { &quot;value&quot; : 0,      &quot;writable&quot; : false, &quot;enumerable&quot; : true,  &quot;configurable&quot; : false });
eval(&quot; function f3() { return 0; } &quot;); // TypeError


However, Safari does not report any exception, while Chrome and Firefox correctly throw the TypeError exceptions.

I&apos;ve tested this using the Web Inspector console of Safari 7.0.4.

Thanks,
Daejun</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1049786</commentid>
    <comment_count>1</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2014-11-19 08:51:54 -0800</bug_when>
    <thetext>Retitling to reflect actual bug - it&apos;s not due to a duplicate function. We&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1049846</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2014-11-19 11:17:52 -0800</bug_when>
    <thetext>&lt;rdar://problem/19032865&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2162843</commentid>
    <comment_count>3</comment_count>
    <who name="Satish Srinivasan">vasan.s</who>
    <bug_when>2025-12-02 23:33:44 -0800</bug_when>
    <thetext>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.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>