Bug 1508672 - Make |new import()| a syntax error r=jorendorff
authorJon Coppeard <jcoppeard@mozilla.com>
Mon, 26 Nov 2018 16:11:44 +0000
changeset 504449 0ee93898e415524e9ffbf569cbcedadd35a67ac6
parent 504448 761da392dd7a800d04d1112d191d25f3cc632484
child 504450 93445c3027525c80ac196074b58976a6c648fd83
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1508672
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1508672 - Make |new import()| a syntax error r=jorendorff
js/src/frontend/Parser.cpp
js/src/frontend/Parser.h
js/src/tests/jstests.list
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -8902,17 +8902,17 @@ GeneralParser<ParseHandler, Unit>::membe
         if (!thisName) {
             return null();
         }
         lhs = handler.newSuperBase(thisName, pos());
         if (!lhs) {
             return null();
         }
     } else if (tt == TokenKind::Import) {
-        lhs = importExpr(yieldHandling);
+        lhs = importExpr(yieldHandling, allowCallSyntax);
         if (!lhs) {
             return null();
         }
     } else {
         lhs = primaryExpr(yieldHandling, tripledotHandling, tt, possibleError, invoked);
         if (!lhs) {
             return null();
         }
@@ -10267,17 +10267,17 @@ GeneralParser<ParseHandler, Unit>::tryNe
     }
 
     *newTarget = handler.newNewTarget(newHolder, targetHolder);
     return !!*newTarget;
 }
 
 template <class ParseHandler, typename Unit>
 typename ParseHandler::BinaryNodeType
-GeneralParser<ParseHandler, Unit>::importExpr(YieldHandling yieldHandling)
+GeneralParser<ParseHandler, Unit>::importExpr(YieldHandling yieldHandling, bool allowCallSyntax)
 {
     MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::Import));
 
     NullaryNodeType importHolder = handler.newPosHolder(pos());
     if (!importHolder) {
         return null();
     }
 
@@ -10301,17 +10301,17 @@ GeneralParser<ParseHandler, Unit>::impor
         }
 
         NullaryNodeType metaHolder = handler.newPosHolder(pos());
         if (!metaHolder) {
             return null();
         }
 
         return handler.newImportMeta(importHolder, metaHolder);
-    } else if (next == TokenKind::LeftParen) {
+    } else if (next == TokenKind::LeftParen && allowCallSyntax) {
         Node arg = assignExpr(InAllowed, yieldHandling, TripledotProhibited);
         if (!arg) {
             return null();
         }
 
         if (!mustMatchToken(TokenKind::RightParen, TokenStream::Operand, JSMSG_PAREN_AFTER_ARGS)) {
             return null();
         }
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -1176,17 +1176,17 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE
     Node primaryExpr(YieldHandling yieldHandling, TripledotHandling tripledotHandling,
                      TokenKind tt, PossibleError* possibleError,
                      InvokedPrediction invoked = PredictUninvoked);
     Node exprInParens(InHandling inHandling, YieldHandling yieldHandling,
                       TripledotHandling tripledotHandling, PossibleError* possibleError = nullptr);
 
     bool tryNewTarget(BinaryNodeType* newTarget);
 
-    BinaryNodeType importExpr(YieldHandling yieldHandling);
+    BinaryNodeType importExpr(YieldHandling yieldHandling, bool allowCallSyntax);
 
     CodeNodeType methodDefinition(uint32_t toStringStart, PropertyType propType,
                                   HandleAtom funName);
 
     /*
      * Additional JS parsers.
      */
     bool functionArguments(YieldHandling yieldHandling, FunctionSyntaxKind kind,
--- a/js/src/tests/jstests.list
+++ b/js/src/tests/jstests.list
@@ -508,37 +508,16 @@ skip script test262/language/expressions
 skip script test262/language/expressions/dynamic-import/indirect-resolution.js
 skip script test262/language/expressions/dynamic-import/eval-export-dflt-expr-cls-named.js
 skip script test262/language/expressions/dynamic-import/for-await-resolution-and-error-agen.js
 skip script test262/language/expressions/dynamic-import/eval-export-dflt-expr-fn-anon.js
 skip script test262/language/expressions/dynamic-import/double-error-resolution-promise.js
 skip script test262/language/expressions/dynamic-import/double-error-resolution.js
 skip script test262/language/expressions/dynamic-import/eval-export-dflt-expr-cls-anon.js
 skip script test262/language/expressions/dynamic-import/namespace/default-property-not-set-own.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-function-return-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-with-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-return-await-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/top-level-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-if-braceless-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-async-arrow-function-await-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-if-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-async-function-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-block-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-else-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-async-gen-await-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-with-expression-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-function-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-while-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-block-labeled-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-else-braceless-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-async-function-return-await-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-arrow-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-arrow-assignment-expression-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-async-function-await-no-new-call-expression.js
-skip script test262/language/expressions/dynamic-import/syntax/invalid/nested-do-while-no-new-call-expression.js
 
 ###########################################################
 # Tests disabled due to issues in test262 importer script #
 ###########################################################
 
 # test262 importer merges all includes in a per directory shell.js file, breaking this harness test case.
 skip script test262/harness/detachArrayBuffer.js