Better error message for import.meta and import() without plugin (#6962)

The correct error was already thrown when they weren't in statement position.
This commit is contained in:
Nicolò Ribaudo 2017-12-03 17:45:37 +01:00 committed by Daniel Tschinder
parent ac72bfbd33
commit 62bbee97d7
4 changed files with 8 additions and 6 deletions

View File

@ -129,11 +129,8 @@ export default class StatementParser extends ExpressionParser {
return this.parseEmptyStatement(node); return this.parseEmptyStatement(node);
case tt._export: case tt._export:
case tt._import: { case tt._import: {
if ( const nextToken = this.lookahead();
(this.hasPlugin("dynamicImport") && if (nextToken.type === tt.parenL || nextToken.type === tt.dot) {
this.lookahead().type === tt.parenL) ||
(this.hasPlugin("importMeta") && this.lookahead().type === tt.dot)
) {
break; break;
} }

View File

@ -1,4 +1,4 @@
{ {
"throws": "Unexpected token, expected \"{\" (1:6)", "throws": "This experimental syntax requires enabling the parser plugin: 'dynamicImport' (1:0)",
"plugins": [] "plugins": []
} }

View File

@ -0,0 +1 @@
import.meta;

View File

@ -0,0 +1,4 @@
{
"throws": "This experimental syntax requires enabling the parser plugin: 'importMeta' (1:7)",
"plugins": []
}