keywords are not allowed as local specifier (#307)

Also fix some error messages to be more specific
This commit is contained in:
Daniel Tschinder
2017-02-10 14:58:44 +01:00
committed by GitHub
parent e049ec3456
commit 4bd682e90b
21 changed files with 59 additions and 29 deletions

View File

@@ -1074,7 +1074,12 @@ pp.parseImportSpecifiers = function (node) {
pp.parseImportSpecifier = function (node) {
const specifier = this.startNode();
specifier.imported = this.parseIdentifier(true);
specifier.local = this.eatContextual("as") ? this.parseIdentifier() : specifier.imported.__clone();
if (this.eatContextual("as")) {
specifier.local = this.parseIdentifier();
} else {
this.checkReservedWord(specifier.imported.name, specifier.start, true, true);
specifier.local = specifier.imported.__clone();
}
this.checkLVal(specifier.local, true, undefined, "import specifier");
node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
};