Skip to content

Commit 5270164

Browse files
committed
import() cannot follow 'new'
1 parent 75a3526 commit 5270164

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/Parser/Parse.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3624,6 +3624,10 @@ ParseNodePtr Parser::ParseTerm(BOOL fAllowCall,
36243624
case tkIMPORT:
36253625
if (m_scriptContext->GetConfig()->IsES6ModuleEnabled() && m_scriptContext->GetConfig()->IsESDynamicImportEnabled())
36263626
{
3627+
if (!fAllowCall)
3628+
{
3629+
Error(ERRTokenAfter, _u("import"), _u("new"));
3630+
}
36273631
this->GetScanner()->Scan();
36283632
ChkCurTokNoScan(tkLParen, ERRnoLparen);
36293633
pnode = ParseImportCall<buildAST>();

test/es6module/dynamic-module-functionality.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,13 @@ var tests = [
400400
//note exclusion of testScript case intentional - running the code from a script loads the module
401401
//then the test from Module uses the one loaded by the script - do not add testScript here
402402
}
403-
},
403+
},
404+
{
405+
name : "Test 'new import()' throws - Bug Issue 5797",
406+
body: function() {
407+
assert.throws(()=>{eval('new import("ModuleSimpleExport.js")')}, SyntaxError);
408+
}
409+
}
404410
];
405411

406412
testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });

0 commit comments

Comments
 (0)