Skip to content

Commit bcc78c9

Browse files
author
Kai Cataldo
committed
Remove this.state.octalPosition
1 parent b1a70f3 commit bcc78c9

3 files changed

Lines changed: 6 additions & 9 deletions

File tree

packages/babel-parser/src/parser/statement.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// @flow
2-
/*:: declare var invariant; */
32

43
import * as N from "../types";
54
import { types as tt, type TokenType } from "../tokenizer/types";
@@ -857,8 +856,10 @@ export default class StatementParser extends ExpressionParser {
857856
while (!this.eat(end)) {
858857
// Track octal literals that occur before a "use strict" directive.
859858
if (!parsedNonDirective && this.state.containsOctal) {
860-
/*:: invariant(this.state.octalPosition !== null) */
861-
octalPositions.push(this.state.octalPosition);
859+
// This octal literal will always occur in a directive and will
860+
// therefore be escaped. Subtract two from the current position to
861+
// account for the "\" character.
862+
octalPositions.push(this.state.pos - 2);
862863
}
863864

864865
const stmt = this.parseStatement(null, topLevel);

packages/babel-parser/src/tokenizer/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ export default class Tokenizer extends LocationParser {
225225
if (!curContext || !curContext.preserveSpace) this.skipSpace();
226226

227227
this.state.containsOctal = false;
228-
this.state.octalPosition = null;
229228
this.state.start = this.state.pos;
230229
this.state.startLoc = this.state.curPosition();
231230
if (this.state.pos >= this.length) {
@@ -1297,10 +1296,7 @@ export default class Tokenizer extends LocationParser {
12971296
} else if (this.state.strict) {
12981297
this.raise(codePos, Errors.StrictOctalLiteral);
12991298
} else if (!this.state.containsOctal) {
1300-
// These properties are only used to throw an error for an octal which occurs
1301-
// in a directive which occurs prior to a "use strict" directive.
13021299
this.state.containsOctal = true;
1303-
this.state.octalPosition = codePos;
13041300
}
13051301
}
13061302

packages/babel-parser/src/tokenizer/state.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ export default class State {
141141
// escape sequences must not be interpreted as keywords.
142142
containsEsc: boolean = false;
143143

144-
// TODO
144+
// Used to throw an error for an octal literal which occurs
145+
// in a directive which occurs prior to a "use strict" directive.
145146
containsOctal: boolean = false;
146-
octalPosition: number | null = null;
147147

148148
// Names of exports store. `default` is stored as a name for both
149149
// `export default foo;` and `export { foo as default };`.

0 commit comments

Comments
 (0)