<?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>14611</bug_id>
          
          <creation_ts>2007-07-13 12:01:47 -0700</creation_ts>
          <short_desc>Incorrect JavaScript const declaration behaviour</short_desc>
          <delta_ts>2012-03-07 00:31:30 -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>523.x (Safari 3)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>31813</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Cameron Zwarich (cpst)">zwarich</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>barraclough</cc>
    
    <cc>bugmail</cc>
    
    <cc>darin</cc>
    
    <cc>dstorey</cc>
    
    <cc>feng</cc>
    
    <cc>webmaster</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>4878</commentid>
    <comment_count>0</comment_count>
    <who name="Cameron Zwarich (cpst)">zwarich</who>
    <bug_when>2007-07-13 12:01:47 -0700</bug_when>
    <thetext>When I was fixing the patch for bug 13517 so that it would past fast/js/const, I realized that const is currently handled incorrectly.

A variable that is declared with either a var declaration or a const declaration can be redeclared (and given a new value) with const, which is against  &lt;http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Statements:const&gt;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4874</commentid>
    <comment_count>1</comment_count>
      <attachid>15503</attachid>
    <who name="Cameron Zwarich (cpst)">zwarich</who>
    <bug_when>2007-07-13 12:04:42 -0700</bug_when>
    <thetext>Created attachment 15503
Test case

Here is a test case.

I have a pretty good idea of a patch, but it depends on the fix for bug 13517, so I will wait until that is resolved.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4745</commentid>
    <comment_count>2</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-07-14 16:01:20 -0700</bug_when>
    <thetext>Confirmed with a local debug build of WebKit r24285 with Safari 3.0 (522.12) on Mac OS X 10.4.10 (8R218).

Opera 9.21.3678 fails as well.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81218</commentid>
    <comment_count>3</comment_count>
    <who name="Cameron Zwarich (cpst)">zwarich</who>
    <bug_when>2008-05-22 11:10:37 -0700</bug_when>
    <thetext>*** Bug 19194 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95696</commentid>
    <comment_count>4</comment_count>
    <who name="Cameron Zwarich (cpst)">zwarich</who>
    <bug_when>2008-10-16 19:59:26 -0700</bug_when>
    <thetext>*** Bug 21700 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118850</commentid>
    <comment_count>5</comment_count>
    <who name="Eli Grey (:sephr)">bugmail</who>
    <bug_when>2009-04-25 16:07:53 -0700</bug_when>
    <thetext>consts can also be deleted. Which is against Mozilla&apos;s spec. Attempting to delete a const should return false and fail (not throwing any errors though).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118851</commentid>
    <comment_count>6</comment_count>
      <attachid>29789</attachid>
    <who name="Eli Grey (:sephr)">bugmail</who>
    <bug_when>2009-04-25 16:09:32 -0700</bug_when>
    <thetext>Created attachment 29789
testcase that also tests deleting a const</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118853</commentid>
    <comment_count>7</comment_count>
    <who name="Cameron Zwarich (cpst)">zwarich</who>
    <bug_when>2009-04-25 16:17:41 -0700</bug_when>
    <thetext>Oh yeah, so much is wrong with our implementation of &apos;const&apos;. In practice, it doesn&apos;t matter at all, because nothing depends on the correct behaviour. We should fix it some day, but I don&apos;t think it is a priority right now given the other bugs that are open.

If someone knows of a site that this breaks, mention it here and I&apos;ll try to fix it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>118855</commentid>
    <comment_count>8</comment_count>
    <who name="Eli Grey (:sephr)">bugmail</who>
    <bug_when>2009-04-25 16:37:02 -0700</bug_when>
    <thetext>(In reply to comment #7)
IMO, it&apos;s pretty important if you want to make library that, if a site scumbs to an XSS flaw, the library reports a bug on itself on a page.
For example:
  const reportXSSFlawedPage = function() { do_some_stuff_with(location.href) };

In Firefox, the website will report an error to the admin so he can get the library fixed ASAP. In WebKit, the XSS attack knows about the &quot;reportXSSFlawedPage&quot; function, and overwrites it. The admin doesn&apos;t find out about the XSS flaw until quite a few users have been affected.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>140729</commentid>
    <comment_count>9</comment_count>
    <who name="Eli Grey (:sephr)">bugmail</who>
    <bug_when>2009-08-17 09:31:25 -0700</bug_when>
    <thetext>*** Bug 21701 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>572642</commentid>
    <comment_count>10</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2012-03-07 00:31:30 -0800</bug_when>
    <thetext>Our const behavior currently doesn&apos;t respect any spec, and therefore can do whatever it wants. :-)

Our intention is to fix this by replacing our current implementation with one that implements Harmony block scoped const; this bug should be subsumed as a part of that change.

*** This bug has been marked as a duplicate of bug 31813 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>15503</attachid>
            <date>2007-07-13 12:04:42 -0700</date>
            <delta_ts>2007-07-13 12:04:42 -0700</delta_ts>
            <desc>Test case</desc>
            <filename>consttest.html</filename>
            <type>text/html</type>
            <size>107</size>
            <attacher name="Cameron Zwarich (cpst)">zwarich</attacher>
            
              <data encoding="base64">PHNjcmlwdD4KdmFyIHggPSAiIjsKY29uc3QgeCA9ICJ3cm9uZyEiOwoKYWxlcnQoeCk7Cgpjb25z
dCB5ID0gIiI7CmNvbnN0IHkgPSAid3JvbmchIjsKCmFsZXJ0KHkpOwo8L3NjcmlwdD4=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>29789</attachid>
            <date>2009-04-25 16:09:32 -0700</date>
            <delta_ts>2009-04-25 16:09:32 -0700</delta_ts>
            <desc>testcase that also tests deleting a const</desc>
            <filename>const.html</filename>
            <type>text/html</type>
            <size>1138</size>
            <attacher name="Eli Grey (:sephr)">bugmail</attacher>
            
              <data encoding="base64">77u/PCFkb2N0eXBlIGh0bWw+CjxodG1sPgo8aGVhZD4KPG1ldGEgY2hhcnNldD0idXRmLTgiLz4K
PHRpdGxlPmNvbnN0IFRlc3RjYXNlPC90aXRsZT4KPHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3Jp
cHQiIHNyYz0iL3hjY2Vzc29ycy9sYXRlc3QveGNjZXNzb3JzLm1pbi5qcyI+PC9zY3JpcHQ+Cjwv
aGVhZD4KPGJvZHk+CjxoMT48Y29kZT5jb25zdDwvY29kZT4gVGVzdGNhc2U8L2gxPgo8c2NyaXB0
IHR5cGU9InRleHQvamF2YXNjcmlwdCIgZGVmZXI9InRydWUiPgovLzwhW0NEQVRBWwoKdmFyIHJl
c3VsdHMgPSAgIiI7Cgpjb25zdCBmb28gPSA1Owpjb25zdCBiYXIgPSA2Owpjb25zdCBiYXogPSA3
Owpjb25zdCBmb29iYXIgPSA4OwoKCnRyeSB7IGV2YWwoInZhciBmb28gPSA0IikgfQpjYXRjaCAo
ZSkge30KCnJlc3VsdHMgKz0gImNvbnN0IGZvbyAg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