From f2b179156b422cb728cc09112eebbef346fa76bc Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Mon, 24 Apr 2023 17:05:15 -0500 Subject: [PATCH] Issue #1691 - Part 15: Make |new import()| a syntax error. https://bugzilla.mozilla.org/show_bug.cgi?id=1508672 (cherry picked from commit 45fda91268b6a3ca8471c8094f2d640ebad682f9) --- js/src/frontend/Parser.cpp | 6 +++--- js/src/frontend/Parser.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index f012823a5e..23b479bfbb 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -9392,7 +9392,7 @@ Parser::memberExpr(YieldHandling yieldHandling, TripledotHandling if (!lhs) return null(); } else if (tt == TOK_IMPORT) { - lhs = importExpr(yieldHandling); + lhs = importExpr(yieldHandling, allowCallSyntax); if (!lhs) return null(); } else { @@ -10579,7 +10579,7 @@ Parser::tryNewTarget(BinaryNodeType* newTarget) template typename ParseHandler::Node -Parser::importExpr(YieldHandling yieldHandling) +Parser::importExpr(YieldHandling yieldHandling, bool allowCallSyntax) { MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_IMPORT)); @@ -10609,7 +10609,7 @@ Parser::importExpr(YieldHandling yieldHandling) return null(); return handler.newImportMeta(importHolder, metaHolder); - } else if (next == TOK_LP) { + } else if (next == TOK_LP && allowCallSyntax) { Node arg = assignExpr(InAllowed, yieldHandling, TripledotProhibited); if (!arg) return null(); diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index 44f4aaf108..fce6ead17d 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -1421,7 +1421,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE) bool tryNewTarget(BinaryNodeType* newTarget); bool checkAndMarkSuperScope(); - Node importExpr(YieldHandling yieldHandling); + Node importExpr(YieldHandling yieldHandling, bool allowCallSyntax); FunctionNodeType methodDefinition(uint32_t toStringStart, PropertyType propType, HandleAtom funName);