[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

@@ -1326,11 +1326,7 @@ export default class Tokenizer extends LocationParser {
readWord(): void {
const word = this.readWord1();
const type = keywordTypes.get(word) || tt.name;
if (type.keyword && this.state.containsEsc) {
this.raise(this.state.pos, `Escape sequence in keyword ${word}`);
}
const type = (!this.state.containsEsc && keywordTypes.get(word)) || tt.name;
// Allow @@iterator and @@asyncIterator as a identifier only inside type
if (