[parser] Report escapes in kws only if they won't be used as i… (#10455)

We can do it by tokenizing escaped keywords as normal identifiers, so that they won't
be accidentally used as real keywords.
This commit is contained in:
Nicolò Ribaudo
2019-09-18 00:13:51 +02:00
committed by GitHub
parent 45a484f0a2
commit cb881e6b3f
9 changed files with 172 additions and 447 deletions

View File

@@ -2066,6 +2066,11 @@ export default class ExpressionParser extends LValParser {
if (this.match(tt.name)) {
name = this.state.value;
// An escaped identifier whose value is the same as a keyword
if (!liberal && this.state.containsEsc && isKeyword(name)) {
this.raise(this.state.pos, `Escape sequence in keyword ${name}`);
}
} else if (this.state.type.keyword) {
name = this.state.type.keyword;