Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove unused invalidTemplateEscapePosition tokenizer state #10935

Merged
merged 2 commits into from Dec 30, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 1 addition & 7 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -1442,13 +1442,7 @@ export default class ExpressionParser extends LValParser {
const elem = this.startNode();
if (this.state.value === null) {
if (!isTagged) {
// TODO: fix this
this.raise(
this.state.invalidTemplateEscapePosition || 0,
"Invalid escape sequence in template",
);
} else {
this.state.invalidTemplateEscapePosition = null;
this.raise(this.state.start + 1, "Invalid escape sequence in template");
}
}
elem.value = {
Expand Down
11 changes: 1 addition & 10 deletions packages/babel-parser/src/tokenizer/index.js
Expand Up @@ -1122,14 +1122,10 @@ export default class Tokenizer extends LocationParser {
throwOnInvalid,
);
++this.state.pos;
if (code === null) {
// $FlowFixMe (is this always non-null?)
--this.state.invalidTemplateEscapePosition; // to point to the '\'' instead of the 'u'
} else if (code > 0x10ffff) {
if (code > 0x10ffff) {
if (throwOnInvalid) {
this.raise(codePos, "Code point out of bounds");
} else {
this.state.invalidTemplateEscapePosition = codePos - 2;
return null;
}
}
Expand Down Expand Up @@ -1274,9 +1270,6 @@ export default class Tokenizer extends LocationParser {
case charCodes.digit8:
case charCodes.digit9:
if (inTemplate) {
const codePos = this.state.pos - 1;

this.state.invalidTemplateEscapePosition = codePos;
return null;
}
default:
Expand All @@ -1299,7 +1292,6 @@ export default class Tokenizer extends LocationParser {
next === charCodes.digit9
) {
if (inTemplate) {
this.state.invalidTemplateEscapePosition = codePos;
return null;
} else if (this.state.strict) {
this.raise(codePos, "Octal literal in strict mode");
Expand Down Expand Up @@ -1332,7 +1324,6 @@ export default class Tokenizer extends LocationParser {
this.raise(codePos, "Bad character escape sequence");
} else {
this.state.pos = codePos - 1;
this.state.invalidTemplateEscapePosition = codePos - 1;
}
}
return n;
Expand Down
2 changes: 0 additions & 2 deletions packages/babel-parser/src/tokenizer/state.js
Expand Up @@ -156,8 +156,6 @@ export default class State {
// `export default foo;` and `export { foo as default };`.
exportedIdentifiers: Array<string> = [];

invalidTemplateEscapePosition: ?number = null;

curPosition(): Position {
return new Position(this.curLine, this.pos - this.lineStart);
}
Expand Down