"static" should not be a reserved keyword in non-strict mode even when ES6 class...
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Mar 2015 00:35:28 +0000 (00:35 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Mar 2015 00:35:28 +0000 (00:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142600

Reviewed by Mark Lam.

Make "static" RESERVED_IF_STRICT and manually detect it in parseClass.

No new tests. This is already checked by js/reserved-words.html and js/keywords-and-reserved_words.html

* parser/Keywords.table:
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseClass):
* parser/ParserTokens.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181419 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/parser/Keywords.table
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/parser/ParserTokens.h

index cd8aa1a0a38e9e1cc2e4a8d261da1741635cb098..46baf571776803f18879f274a6e2cea62bb61917 100644 (file)
@@ -1,3 +1,19 @@
+2015-03-11  Ryosuke Niwa  <rniwa@webkit.org>
+
+        "static" should not be a reserved keyword in non-strict mode even when ES6 class is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=142600
+
+        Reviewed by Mark Lam.
+
+        Make "static" RESERVED_IF_STRICT and manually detect it in parseClass.
+
+        No new tests. This is already checked by js/reserved-words.html and js/keywords-and-reserved_words.html
+
+        * parser/Keywords.table:
+        * parser/Parser.cpp:
+        (JSC::Parser<LexerType>::parseClass):
+        * parser/ParserTokens.h:
+
 2015-03-11  Geoffrey Garen  <ggaren@apple.com>
 
         Many users of Heap::reportExtraMemory* are wrong, causing lots of memory growth
index 873cb9d83c28c410c0be0a810db0d6e36589e6da..3c3f95f8706d1c708d71279f0c53dd9af235484d 100644 (file)
@@ -30,7 +30,6 @@ do            DO
 while          WHILE
 else           ELSE
 in             INTOKEN
-static         STATICTOKEN
 super          SUPER
 switch         SWITCH
 throw          THROW
@@ -52,6 +51,7 @@ package         RESERVED_IF_STRICT
 private         RESERVED_IF_STRICT
 protected       RESERVED_IF_STRICT
 public          RESERVED_IF_STRICT
+static          RESERVED_IF_STRICT
 yield           RESERVED_IF_STRICT
 
 @end
index 12e483b35984168e6382891c308240f4ba816cac..9b7224cc8296746e4a29185870d51d64eacc842c 100644 (file)
@@ -1491,7 +1491,8 @@ template <class TreeBuilder> TreeClassExpression Parser<LexerType>::parseClass(T
         JSTokenLocation methodLocation(tokenLocation());
         unsigned methodStart = tokenStart();
 
-        bool isStaticMethod = match(STATICTOKEN);
+        // For backwards compatibility, "static" is a non-reserved keyword in non-strict mode.
+        bool isStaticMethod = match(RESERVED_IF_STRICT) && *m_token.m_data.ident == m_vm->propertyNames->staticKeyword;
         if (isStaticMethod)
             next();
 
index 3ff279866af6e28690bc07c5f721bc7a38056ea2..0574b72eb683dde43370e61ee58b8b87c6e0d6da 100644 (file)
@@ -78,12 +78,10 @@ enum JSTokenType {
 #if ENABLE(ES6_CLASS_SYNTAX)
     CLASSTOKEN,
     EXTENDS,
-    STATICTOKEN,
     SUPER,
 #else
     CLASSTOKEN = RESERVED,
     EXTENDS = RESERVED,
-    STATICTOKEN = RESERVED_IF_STRICT,
     SUPER = RESERVED,
 #endif
     OPENBRACE = 0,