ASSERTION FAILED: matchContextualKeyword(m_vm->propertyNames->async)
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Mar 2018 05:55:39 +0000 (05:55 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Mar 2018 05:55:39 +0000 (05:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183173

Reviewed by Saam Barati.

JSTests:

* stress/async-arrow-function-in-class-heritage.js: Added.
(testSyntax):
(testSyntaxError):
(SyntaxError):

Source/JavaScriptCore:

Classifier could propagate an error which does not occur at the first token
of the given expression. We should check whether the given token is "async"
instead of assertion.

* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseAssignmentExpression):

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

JSTests/ChangeLog
JSTests/stress/async-arrow-function-in-class-heritage.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/parser/Parser.cpp

index 204f0c0..3b5692a 100644 (file)
@@ -1,3 +1,15 @@
+2018-03-01  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        ASSERTION FAILED: matchContextualKeyword(m_vm->propertyNames->async)
+        https://bugs.webkit.org/show_bug.cgi?id=183173
+
+        Reviewed by Saam Barati.
+
+        * stress/async-arrow-function-in-class-heritage.js: Added.
+        (testSyntax):
+        (testSyntaxError):
+        (SyntaxError):
+
 2018-03-01  Saam Barati  <sbarati@apple.com>
 
         We need to clear cached structures when having a bad time
diff --git a/JSTests/stress/async-arrow-function-in-class-heritage.js b/JSTests/stress/async-arrow-function-in-class-heritage.js
new file mode 100644 (file)
index 0000000..3e5c94f
--- /dev/null
@@ -0,0 +1,25 @@
+function testSyntax(script) {
+    try {
+        eval(script);
+    } catch (error) {
+        if (error instanceof SyntaxError)
+            throw new Error("Bad error: " + String(error));
+    }
+}
+
+function testSyntaxError(script, message) {
+    var error = null;
+    try {
+        eval(script);
+    } catch (e) {
+        error = e;
+    }
+    if (!error)
+        throw new Error("Expected syntax error not thrown");
+
+    if (String(error) !== message)
+        throw new Error("Bad error: " + String(error));
+}
+
+testSyntaxError(`void class extends async()=>{} {}`, `SyntaxError: Unexpected token '=>'`);
+testSyntaxError(`void class extends (async()=>{}) {}`, `TypeError: The value of the superclass's prototype property is not an object.`);
index 72eb929..cd42c9b 100644 (file)
@@ -1,3 +1,17 @@
+2018-03-01  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        ASSERTION FAILED: matchContextualKeyword(m_vm->propertyNames->async)
+        https://bugs.webkit.org/show_bug.cgi?id=183173
+
+        Reviewed by Saam Barati.
+
+        Classifier could propagate an error which does not occur at the first token
+        of the given expression. We should check whether the given token is "async"
+        instead of assertion.
+
+        * parser/Parser.cpp:
+        (JSC::Parser<LexerType>::parseAssignmentExpression):
+
 2018-03-01  Saam Barati  <sbarati@apple.com>
 
         We need to clear cached structures when having a bad time
index 93effa3..72543fd 100644 (file)
@@ -3637,9 +3637,10 @@ template <typename TreeBuilder> TreeExpression Parser<LexerType>::parseAssignmen
             restoreSavePoint(savePoint);
             bool isAsyncArrow = false;
             if (UNLIKELY(classifier.indicatesPossibleAsyncArrowFunction())) {
-                ASSERT(matchContextualKeyword(m_vm->propertyNames->async));
-                next();
-                isAsyncArrow = !m_lexer->prevTerminator();
+                if (matchContextualKeyword(m_vm->propertyNames->async)) {
+                    next();
+                    isAsyncArrow = !m_lexer->prevTerminator();
+                }
             }
             if (isArrowFunctionParameters()) {
                 if (wasOpenParen)