test: add invalid-lone-import test (#10950)

* test: add lone import test

* polish: raise recoverable error
This commit is contained in:
Huáng Jùnliàng
2020-01-03 17:08:59 -05:00
committed by Nicolò Ribaudo
parent a28353703f
commit 455d782ef0
4 changed files with 80 additions and 1 deletions

View File

@@ -919,7 +919,10 @@ export default class ExpressionParser extends LValParser {
this.expectPlugin("dynamicImport", node.start);
if (!this.match(tt.parenL)) {
this.unexpected(null, tt.parenL);
this.raise(
this.state.lastTokStart,
"import can only be used in import() or import.meta",
);
}
return this.finishNode(node, "Import");
case tt._this: