<?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>32721</bug_id>
          
          <creation_ts>2009-12-18 10:17:07 -0800</creation_ts>
          <short_desc>Allow Reserved Words in Object Literals</short_desc>
          <delta_ts>2011-01-24 07:32:52 -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>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>42471</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>ES5</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Joseph Pecoraro">joepeck</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>erights</cc>
    
    <cc>inimino</cc>
    
    <cc>jwalden+bwo</cc>
    
    <cc>pmuellr</cc>
    
    <cc>skyul</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>173212</commentid>
    <comment_count>0</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2009-12-18 10:17:07 -0800</bug_when>
    <thetext>Currently JavaScriptCore does not allow reserved words as property names in Object Literals:

  jsc&gt; var x = { import: 1 };
  Exception: SyntaxError: Parse error

Other browsers seem to allow this right now. The above works in Chrome 4, FF 3.5, and Opera 10.

The Grammar rules are different. Notice that the last step is different (IdentifierName instead of Identifier).

ES3:

  ObjectLiteral
   → PropertyNameAndValueList
    → PropertyName
     → Identifier

ES5:

  ObjectLiteral
   → PropertyNameAndValueList
    → PropertyAssignment
     → PropertyName
      → IdentifierName


Workaround: (this is what JSON ended up doing)

  jsc&gt; var x = { &apos;import&apos;: 1 };
  jsc&gt; x[&apos;import&apos;]; // 1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>177676</commentid>
    <comment_count>1</comment_count>
    <who name="Patrick Mueller">pmuellr</who>
    <bug_when>2010-01-06 11:50:00 -0800</bug_when>
    <thetext>See also Bug 32721, as that bug and this one can possibly be addressed with the similar patch to the grammar.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>339002</commentid>
    <comment_count>2</comment_count>
    <who name="Jeff Walden (remove +bwo to email)">jwalden+bwo</who>
    <bug_when>2011-01-24 07:32:52 -0800</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 42471 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>