Unify reserved word checking and update error messages (#9402)

* Unify reserved word checking and update error messages

* Fix test
This commit is contained in:
Daniel Tschinder
2019-01-31 19:02:32 -08:00
committed by GitHub
parent 7e9029e337
commit 9eb010da50
172 changed files with 347 additions and 331 deletions

View File

@@ -14,10 +14,7 @@ import type {
SpreadElement,
} from "../types";
import type { Pos, Position } from "../util/location";
import {
isStrictReservedWord,
isStrictBindReservedWord,
} from "../util/identifier";
import { isStrictBindReservedWord } from "../util/identifier";
import { NodeUtils } from "./node";
export default class LValParser extends NodeUtils {
@@ -336,12 +333,13 @@ export default class LValParser extends NodeUtils {
case "Identifier":
if (
this.state.strict &&
(isStrictReservedWord(expr.name) ||
isStrictBindReservedWord(expr.name))
isStrictBindReservedWord(expr.name, this.inModule)
) {
this.raise(
expr.start,
expr.name + " is a reserved word in strict mode",
`${isBinding ? "Binding" : "Assigning to"} '${
expr.name
}' in strict mode`,
);
}