Disallow SpreadElement inside dynamic import (#529)
* Disallow SpreadElement inside dynamic import * tweak error message
This commit is contained in:
parent
23ff45fcfa
commit
dcef4012a0
@ -314,8 +314,15 @@ export default class ExpressionParser extends LValParser {
|
||||
const node = this.startNodeAt(startPos, startLoc);
|
||||
node.callee = base;
|
||||
node.arguments = this.parseCallExpressionArguments(tt.parenR, possibleAsync);
|
||||
if (node.callee.type === "Import" && node.arguments.length !== 1) {
|
||||
this.raise(node.start, "import() requires exactly one argument");
|
||||
if (node.callee.type === "Import") {
|
||||
if (node.arguments.length !== 1) {
|
||||
this.raise(node.start, "import() requires exactly one argument");
|
||||
}
|
||||
|
||||
const importArg = node.arguments[0];
|
||||
if (importArg && importArg.type === "SpreadElement") {
|
||||
this.raise(importArg.start, "... is not allowed in import()");
|
||||
}
|
||||
}
|
||||
base = this.finishNode(node, "CallExpression");
|
||||
|
||||
|
||||
1
test/fixtures/experimental/dynamic-import/invalid-arguments-spread/actual.js
vendored
Normal file
1
test/fixtures/experimental/dynamic-import/invalid-arguments-spread/actual.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
import(...[1])
|
||||
3
test/fixtures/experimental/dynamic-import/invalid-arguments-spread/options.json
vendored
Normal file
3
test/fixtures/experimental/dynamic-import/invalid-arguments-spread/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "... is not allowed in import() (1:7)"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user