diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index a4564a5c61..91f49064c3 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -55,6 +55,7 @@ export default class ExpressionParser extends LValParser { +parseBlock: ( allowDirectives?: boolean, createNewLexicalScope?: boolean, + afterBlockParse?: (hasStrictModeDirective: boolean) => void, ) => N.BlockStatement; +parseClass: ( node: N.Class, @@ -1877,9 +1878,6 @@ export default class ExpressionParser extends LValParser { isMethod?: boolean = false, ): void { const isExpression = allowExpression && !this.match(tt.braceL); - const oldStrict = this.state.strict; - let useStrict = false; - const oldInParameters = this.state.inParameters; this.state.inParameters = false; @@ -1887,58 +1885,63 @@ export default class ExpressionParser extends LValParser { node.body = this.parseMaybeAssign(); this.checkParams(node, false, allowExpression, false); } else { - const nonSimple = !this.isSimpleParamList(node.params); - if (!oldStrict || nonSimple) { - useStrict = this.strictDirective(this.state.end); - // If this is a strict mode function, verify that argument names - // are not repeated, and it does not try to bind the words `eval` - // or `arguments`. - if (useStrict && nonSimple) { - // This logic is here to align the error location with the estree plugin - const errorPos = - // $FlowIgnore - (node.kind === "method" || node.kind === "constructor") && - // $FlowIgnore - !!node.key - ? node.key.end - : node.start; - this.raise(errorPos, Errors.IllegalLanguageModeDirective); - } - } + const oldStrict = this.state.strict; // Start a new scope with regard to labels // flag (restore them to their old value afterwards). const oldLabels = this.state.labels; this.state.labels = []; - if (useStrict) this.state.strict = true; - // Add the params to varDeclaredNames to ensure that an error is thrown - // if a let/const declaration in the function clashes with one of the params. - this.checkParams( - node, - !oldStrict && !useStrict && !allowExpression && !isMethod && !nonSimple, - allowExpression, - !oldStrict && useStrict, - ); + // FunctionBody[Yield, Await]: // StatementList[?Yield, ?Await, +Return] opt this.prodParam.enter(this.prodParam.currentFlags() | PARAM_RETURN); - node.body = this.parseBlock(true, false); + node.body = this.parseBlock( + true, + false, + // Strict mode function checks after we parse the statements in the function body. + (hasStrictModeDirective: boolean) => { + const nonSimple = !this.isSimpleParamList(node.params); + + if (hasStrictModeDirective && nonSimple) { + // This logic is here to align the error location with the ESTree plugin. + const errorPos = + // $FlowIgnore + (node.kind === "method" || node.kind === "constructor") && + // $FlowIgnore + !!node.key + ? node.key.end + : node.start; + this.raise(errorPos, Errors.IllegalLanguageModeDirective); + } + + const strictModeChanged = !oldStrict && this.state.strict; + + // Add the params to varDeclaredNames to ensure that an error is thrown + // if a let/const declaration in the function clashes with one of the params. + this.checkParams( + node, + !this.state.strict && !allowExpression && !isMethod && !nonSimple, + allowExpression, + strictModeChanged, + ); + + // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' + if (this.state.strict && node.id) { + this.checkLVal( + node.id, + BIND_OUTSIDE, + undefined, + "function name", + undefined, + strictModeChanged, + ); + } + }, + ); this.prodParam.exit(); this.state.labels = oldLabels; } this.state.inParameters = oldInParameters; - // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' - if (this.state.strict && node.id) { - this.checkLVal( - node.id, - BIND_OUTSIDE, - undefined, - "function name", - undefined, - !oldStrict && useStrict, - ); - } - this.state.strict = oldStrict; } isSimpleParamList( diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index c23b3b82e0..7c435b4aa1 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -795,13 +795,20 @@ export default class StatementParser extends ExpressionParser { parseBlock( allowDirectives?: boolean = false, createNewLexicalScope?: boolean = true, + afterBlockParse?: (hasStrictModeDirective: boolean) => void, ): N.BlockStatement { const node = this.startNode(); this.expect(tt.braceL); if (createNewLexicalScope) { this.scope.enter(SCOPE_OTHER); } - this.parseBlockBody(node, allowDirectives, false, tt.braceR); + this.parseBlockBody( + node, + allowDirectives, + false, + tt.braceR, + afterBlockParse, + ); if (createNewLexicalScope) { this.scope.exit(); } @@ -821,6 +828,7 @@ export default class StatementParser extends ExpressionParser { allowDirectives: ?boolean, topLevel: boolean, end: TokenType, + afterBlockParse?: (hasStrictModeDirective: boolean) => void, ): void { const body = (node.body = []); const directives = (node.directives = []); @@ -829,6 +837,7 @@ export default class StatementParser extends ExpressionParser { allowDirectives ? directives : undefined, topLevel, end, + afterBlockParse, ); } @@ -838,14 +847,16 @@ export default class StatementParser extends ExpressionParser { directives: ?(N.Directive[]), topLevel: boolean, end: TokenType, + afterBlockParse?: (hasStrictModeDirective: boolean) => void, ): void { + const octalPositions = []; let parsedNonDirective = false; - let oldStrict; - let octalPosition; + let oldStrict = null; while (!this.eat(end)) { - if (!parsedNonDirective && this.state.containsOctal && !octalPosition) { - octalPosition = this.state.octalPosition; + // Track octal literals that occur before a "use strict" directive. + if (!parsedNonDirective && this.state.octalPositions.length) { + octalPositions.push(...this.state.octalPositions); } const stmt = this.parseStatement(null, topLevel); @@ -854,13 +865,9 @@ export default class StatementParser extends ExpressionParser { const directive = this.stmtToDirective(stmt); directives.push(directive); - if (oldStrict === undefined && directive.value.value === "use strict") { + if (oldStrict === null && directive.value.value === "use strict") { oldStrict = this.state.strict; this.setStrict(true); - - if (octalPosition) { - this.raise(octalPosition, Errors.StrictOctalLiteral); - } } continue; @@ -870,6 +877,22 @@ export default class StatementParser extends ExpressionParser { body.push(stmt); } + // Throw an error for any octal literals found before a + // "use strict" directive. Strict mode will be set at parse + // time for any literals that occur after the directive. + if (this.state.strict && octalPositions.length) { + for (const pos of octalPositions) { + this.raise(pos, Errors.StrictOctalLiteral); + } + } + + if (afterBlockParse) { + afterBlockParse.call( + this, + /* hasStrictModeDirective */ oldStrict !== null, + ); + } + if (oldStrict === false) { this.setStrict(false); } diff --git a/packages/babel-parser/src/parser/util.js b/packages/babel-parser/src/parser/util.js index dc6580fcc4..1ac2dbd744 100644 --- a/packages/babel-parser/src/parser/util.js +++ b/packages/babel-parser/src/parser/util.js @@ -4,13 +4,11 @@ import { types as tt, type TokenType } from "../tokenizer/types"; import Tokenizer from "../tokenizer"; import State from "../tokenizer/state"; import type { Node } from "../types"; -import { lineBreak, skipWhiteSpace } from "../util/whitespace"; +import { lineBreak } from "../util/whitespace"; import { isIdentifierChar } from "../util/identifier"; import * as charCodes from "charcodes"; import { Errors } from "./location"; -const literal = /^('|")((?:\\?.)*?)\1/; - type TryParse = { node: Node, error: Error, @@ -193,29 +191,6 @@ export default class UtilParser extends Tokenizer { } } - strictDirective(start: number): boolean { - for (;;) { - // Try to find string literal. - skipWhiteSpace.lastIndex = start; - // $FlowIgnore - start += skipWhiteSpace.exec(this.input)[0].length; - const match = literal.exec(this.input.slice(start)); - if (!match) break; - if (match[2] === "use strict") return true; - start += match[0].length; - - // Skip semicolon, if any. - skipWhiteSpace.lastIndex = start; - // $FlowIgnore - start += skipWhiteSpace.exec(this.input)[0].length; - if (this.input[start] === ";") { - start++; - } - } - - return false; - } - // tryParse will clone parser state. // It is expensive and should be used with cautions tryParse>( diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index 7ab2fd2540..0f250ce6e0 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -224,8 +224,7 @@ export default class Tokenizer extends LocationParser { const curContext = this.curContext(); if (!curContext || !curContext.preserveSpace) this.skipSpace(); - this.state.containsOctal = false; - this.state.octalPosition = null; + this.state.octalPositions = []; this.state.start = this.state.pos; this.state.startLoc = this.state.curPosition(); if (this.state.pos >= this.length) { @@ -1033,11 +1032,7 @@ export default class Tokenizer extends LocationParser { this.input.charCodeAt(start) === charCodes.digit0; if (octal) { if (this.state.strict) { - this.raise( - start, - // todo: merge with Errors.StrictOctalLiteral - "Legacy octal literals are not allowed in strict mode", - ); + this.raise(start, Errors.StrictOctalLiteral); } if (/[89]/.test(this.input.slice(start, this.state.pos))) { octal = false; @@ -1296,11 +1291,11 @@ export default class Tokenizer extends LocationParser { return null; } else if (this.state.strict) { this.raise(codePos, Errors.StrictOctalLiteral); - } else if (!this.state.containsOctal) { - // These properties are only used to throw an error for an octal which occurs - // in a directive which occurs prior to a "use strict" directive. - this.state.containsOctal = true; - this.state.octalPosition = codePos; + } else { + // This property is used to throw an error for + // an octal literal in a directive that occurs prior + // to a "use strict" directive. + this.state.octalPositions.push(codePos); } } diff --git a/packages/babel-parser/src/tokenizer/state.js b/packages/babel-parser/src/tokenizer/state.js index d3a8747803..37cb3a413c 100644 --- a/packages/babel-parser/src/tokenizer/state.js +++ b/packages/babel-parser/src/tokenizer/state.js @@ -141,9 +141,10 @@ export default class State { // escape sequences must not be interpreted as keywords. containsEsc: boolean = false; - // TODO - containsOctal: boolean = false; - octalPosition: ?number = null; + // This property is used to throw an error for + // an octal literal in a directive that occurs prior + // to a "use strict" directive. + octalPositions: number[] = []; // Names of exports store. `default` is stored as a name for both // `export default foo;` and `export { foo as default };`. diff --git a/packages/babel-parser/test/fixtures/core/categorized/not-directive/input.js b/packages/babel-parser/test/fixtures/core/categorized/not-directive/input.js index 2392784f31..4ac4c61819 100644 --- a/packages/babel-parser/test/fixtures/core/categorized/not-directive/input.js +++ b/packages/babel-parser/test/fixtures/core/categorized/not-directive/input.js @@ -1 +1,118 @@ -("not a directive"); +("use strict"); + +"use strict".foo; +"use strict"[foo]; +"use strict"`foo`; +"use strict"(foo); +"use strict" + .foo; +"use strict" + [foo]; +"use strict" + `foo`; +"use strict" + (foo); + +// Should not be a syntax error because should not be parsed in strict mode. +"\5"; + +function f(){ + "use strict".foo; + "\5"; +} + +function f(){ + "use strict"[foo]; + "\5"; +} + +function f(){ + "use strict"`foo`; + "\5"; +} + +function f(){ + "use strict"(foo); + "\5"; +} + +function f(){ + "use strict" + .foo; + "\5"; +} + +function f(){ + "use strict" + [foo]; + "\5"; +} + +function f(){ + "use strict" + `foo`; + "\5"; +} + +function f(){ + "use strict" + (foo); + "\5"; +} + +function f(){ + foo(); + "use strict".bar; + "\5"; +} + +function f(){ + foo(); + "use strict"[bar]; + "\5"; +} + +function f(){ + foo(); + "use strict"`bar`; + "\5"; +} + +function f(){ + foo(); + "use strict"(bar); + "\5"; +} + +function f(){ + foo(); + "use strict" + .bar; + "\5"; +} + +function f(){ + foo(); + "use strict" + [bar]; + "\5"; +} + +function f(){ + foo(); + "use strict" + `bar`; + "\5"; +} + +function f(){ + foo(); + "use strict" + (bar); + "\5"; +} + +function f(){ + 05; + "use strict"; +} diff --git a/packages/babel-parser/test/fixtures/core/categorized/not-directive/output.json b/packages/babel-parser/test/fixtures/core/categorized/not-directive/output.json index ff0caba117..2ada86e94d 100644 --- a/packages/babel-parser/test/fixtures/core/categorized/not-directive/output.json +++ b/packages/babel-parser/test/fixtures/core/categorized/not-directive/output.json @@ -1,29 +1,29 @@ { "type": "File", "start": 0, - "end": 20, + "end": 1129, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 20 + "line": 118, + "column": 1 } }, "program": { "type": "Program", "start": 0, - "end": 20, + "end": 1129, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 20 + "line": 118, + "column": 1 } }, "sourceType": "script", @@ -32,7 +32,7 @@ { "type": "ExpressionStatement", "start": 0, - "end": 20, + "end": 15, "loc": { "start": { "line": 1, @@ -40,13 +40,13 @@ }, "end": { "line": 1, - "column": 20 + "column": 15 } }, "expression": { "type": "StringLiteral", "start": 1, - "end": 18, + "end": 13, "loc": { "start": { "line": 1, @@ -54,19 +54,3781 @@ }, "end": { "line": 1, - "column": 18 + "column": 13 } }, "extra": { - "rawValue": "not a directive", - "raw": "\"not a directive\"", + "rawValue": "use strict", + "raw": "\"use strict\"", "parenthesized": true, "parenStart": 0 }, - "value": "not a directive" + "value": "use strict" + } + }, + { + "type": "ExpressionStatement", + "start": 17, + "end": 34, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "expression": { + "type": "MemberExpression", + "start": 17, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "object": { + "type": "StringLiteral", + "start": 17, + "end": 29, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "property": { + "type": "Identifier", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false + } + }, + { + "type": "ExpressionStatement", + "start": 35, + "end": 53, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "expression": { + "type": "MemberExpression", + "start": 35, + "end": 52, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 17 + } + }, + "object": { + "type": "StringLiteral", + "start": 35, + "end": 47, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 12 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "property": { + "type": "Identifier", + "start": 48, + "end": 51, + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": true + } + }, + { + "type": "ExpressionStatement", + "start": 54, + "end": 72, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 18 + } + }, + "expression": { + "type": "TaggedTemplateExpression", + "start": 54, + "end": 71, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 17 + } + }, + "tag": { + "type": "StringLiteral", + "start": 54, + "end": 66, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 12 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "quasi": { + "type": "TemplateLiteral", + "start": 66, + "end": 71, + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 17 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 67, + "end": 70, + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "value": { + "raw": "foo", + "cooked": "foo" + }, + "tail": true + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start": 73, + "end": 91, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 18 + } + }, + "expression": { + "type": "CallExpression", + "start": 73, + "end": 90, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "callee": { + "type": "StringLiteral", + "start": 73, + "end": 85, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "arguments": [ + { + "type": "Identifier", + "start": 86, + "end": 89, + "loc": { + "start": { + "line": 6, + "column": 13 + }, + "end": { + "line": 6, + "column": 16 + }, + "identifierName": "foo" + }, + "name": "foo" + } + ] + } + }, + { + "type": "ExpressionStatement", + "start": 92, + "end": 112, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "expression": { + "type": "MemberExpression", + "start": 92, + "end": 111, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 8, + "column": 6 + } + }, + "object": { + "type": "StringLiteral", + "start": 92, + "end": 104, + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "property": { + "type": "Identifier", + "start": 108, + "end": 111, + "loc": { + "start": { + "line": 8, + "column": 3 + }, + "end": { + "line": 8, + "column": 6 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false + } + }, + { + "type": "ExpressionStatement", + "start": 113, + "end": 134, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 10, + "column": 8 + } + }, + "expression": { + "type": "MemberExpression", + "start": 113, + "end": 133, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 10, + "column": 7 + } + }, + "object": { + "type": "StringLiteral", + "start": 113, + "end": 125, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 12 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "property": { + "type": "Identifier", + "start": 129, + "end": 132, + "loc": { + "start": { + "line": 10, + "column": 3 + }, + "end": { + "line": 10, + "column": 6 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": true + } + }, + { + "type": "ExpressionStatement", + "start": 135, + "end": 156, + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 12, + "column": 8 + } + }, + "expression": { + "type": "TaggedTemplateExpression", + "start": 135, + "end": 155, + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 12, + "column": 7 + } + }, + "tag": { + "type": "StringLiteral", + "start": 135, + "end": 147, + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 12 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "quasi": { + "type": "TemplateLiteral", + "start": 150, + "end": 155, + "loc": { + "start": { + "line": 12, + "column": 2 + }, + "end": { + "line": 12, + "column": 7 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 151, + "end": 154, + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 6 + } + }, + "value": { + "raw": "foo", + "cooked": "foo" + }, + "tail": true + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start": 157, + "end": 178, + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 14, + "column": 8 + } + }, + "expression": { + "type": "CallExpression", + "start": 157, + "end": 177, + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 14, + "column": 7 + } + }, + "callee": { + "type": "StringLiteral", + "start": 157, + "end": 169, + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 12 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "arguments": [ + { + "type": "Identifier", + "start": 173, + "end": 176, + "loc": { + "start": { + "line": 14, + "column": 3 + }, + "end": { + "line": 14, + "column": 6 + }, + "identifierName": "foo" + }, + "name": "foo" + } + ] + }, + "trailingComments": [ + { + "type": "CommentLine", + "value": " Should not be a syntax error because should not be parsed in strict mode.", + "start": 180, + "end": 256, + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 76 + } + } + } + ] + }, + { + "type": "ExpressionStatement", + "start": 257, + "end": 262, + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 5 + } + }, + "expression": { + "type": "StringLiteral", + "start": 257, + "end": 261, + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 4 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": " Should not be a syntax error because should not be parsed in strict mode.", + "start": 180, + "end": 256, + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 76 + } + } + } + ] + }, + { + "type": "FunctionDeclaration", + "start": 264, + "end": 307, + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 22, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 273, + "end": 274, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 276, + "end": 307, + "loc": { + "start": { + "line": 19, + "column": 12 + }, + "end": { + "line": 22, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 280, + "end": 297, + "loc": { + "start": { + "line": 20, + "column": 2 + }, + "end": { + "line": 20, + "column": 19 + } + }, + "expression": { + "type": "MemberExpression", + "start": 280, + "end": 296, + "loc": { + "start": { + "line": 20, + "column": 2 + }, + "end": { + "line": 20, + "column": 18 + } + }, + "object": { + "type": "StringLiteral", + "start": 280, + "end": 292, + "loc": { + "start": { + "line": 20, + "column": 2 + }, + "end": { + "line": 20, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "property": { + "type": "Identifier", + "start": 293, + "end": 296, + "loc": { + "start": { + "line": 20, + "column": 15 + }, + "end": { + "line": 20, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false + } + }, + { + "type": "ExpressionStatement", + "start": 300, + "end": 305, + "loc": { + "start": { + "line": 21, + "column": 2 + }, + "end": { + "line": 21, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 300, + "end": 304, + "loc": { + "start": { + "line": 21, + "column": 2 + }, + "end": { + "line": 21, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 309, + "end": 353, + "loc": { + "start": { + "line": 24, + "column": 0 + }, + "end": { + "line": 27, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 318, + "end": 319, + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 321, + "end": 353, + "loc": { + "start": { + "line": 24, + "column": 12 + }, + "end": { + "line": 27, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 325, + "end": 343, + "loc": { + "start": { + "line": 25, + "column": 2 + }, + "end": { + "line": 25, + "column": 20 + } + }, + "expression": { + "type": "MemberExpression", + "start": 325, + "end": 342, + "loc": { + "start": { + "line": 25, + "column": 2 + }, + "end": { + "line": 25, + "column": 19 + } + }, + "object": { + "type": "StringLiteral", + "start": 325, + "end": 337, + "loc": { + "start": { + "line": 25, + "column": 2 + }, + "end": { + "line": 25, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "property": { + "type": "Identifier", + "start": 338, + "end": 341, + "loc": { + "start": { + "line": 25, + "column": 15 + }, + "end": { + "line": 25, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": true + } + }, + { + "type": "ExpressionStatement", + "start": 346, + "end": 351, + "loc": { + "start": { + "line": 26, + "column": 2 + }, + "end": { + "line": 26, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 346, + "end": 350, + "loc": { + "start": { + "line": 26, + "column": 2 + }, + "end": { + "line": 26, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 355, + "end": 399, + "loc": { + "start": { + "line": 29, + "column": 0 + }, + "end": { + "line": 32, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 364, + "end": 365, + "loc": { + "start": { + "line": 29, + "column": 9 + }, + "end": { + "line": 29, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 367, + "end": 399, + "loc": { + "start": { + "line": 29, + "column": 12 + }, + "end": { + "line": 32, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 371, + "end": 389, + "loc": { + "start": { + "line": 30, + "column": 2 + }, + "end": { + "line": 30, + "column": 20 + } + }, + "expression": { + "type": "TaggedTemplateExpression", + "start": 371, + "end": 388, + "loc": { + "start": { + "line": 30, + "column": 2 + }, + "end": { + "line": 30, + "column": 19 + } + }, + "tag": { + "type": "StringLiteral", + "start": 371, + "end": 383, + "loc": { + "start": { + "line": 30, + "column": 2 + }, + "end": { + "line": 30, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "quasi": { + "type": "TemplateLiteral", + "start": 383, + "end": 388, + "loc": { + "start": { + "line": 30, + "column": 14 + }, + "end": { + "line": 30, + "column": 19 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 384, + "end": 387, + "loc": { + "start": { + "line": 30, + "column": 15 + }, + "end": { + "line": 30, + "column": 18 + } + }, + "value": { + "raw": "foo", + "cooked": "foo" + }, + "tail": true + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start": 392, + "end": 397, + "loc": { + "start": { + "line": 31, + "column": 2 + }, + "end": { + "line": 31, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 392, + "end": 396, + "loc": { + "start": { + "line": 31, + "column": 2 + }, + "end": { + "line": 31, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 401, + "end": 445, + "loc": { + "start": { + "line": 34, + "column": 0 + }, + "end": { + "line": 37, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 410, + "end": 411, + "loc": { + "start": { + "line": 34, + "column": 9 + }, + "end": { + "line": 34, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 413, + "end": 445, + "loc": { + "start": { + "line": 34, + "column": 12 + }, + "end": { + "line": 37, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 417, + "end": 435, + "loc": { + "start": { + "line": 35, + "column": 2 + }, + "end": { + "line": 35, + "column": 20 + } + }, + "expression": { + "type": "CallExpression", + "start": 417, + "end": 434, + "loc": { + "start": { + "line": 35, + "column": 2 + }, + "end": { + "line": 35, + "column": 19 + } + }, + "callee": { + "type": "StringLiteral", + "start": 417, + "end": 429, + "loc": { + "start": { + "line": 35, + "column": 2 + }, + "end": { + "line": 35, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "arguments": [ + { + "type": "Identifier", + "start": 430, + "end": 433, + "loc": { + "start": { + "line": 35, + "column": 15 + }, + "end": { + "line": 35, + "column": 18 + }, + "identifierName": "foo" + }, + "name": "foo" + } + ] + } + }, + { + "type": "ExpressionStatement", + "start": 438, + "end": 443, + "loc": { + "start": { + "line": 36, + "column": 2 + }, + "end": { + "line": 36, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 438, + "end": 442, + "loc": { + "start": { + "line": 36, + "column": 2 + }, + "end": { + "line": 36, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 447, + "end": 493, + "loc": { + "start": { + "line": 39, + "column": 0 + }, + "end": { + "line": 43, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 456, + "end": 457, + "loc": { + "start": { + "line": 39, + "column": 9 + }, + "end": { + "line": 39, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 459, + "end": 493, + "loc": { + "start": { + "line": 39, + "column": 12 + }, + "end": { + "line": 43, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 463, + "end": 483, + "loc": { + "start": { + "line": 40, + "column": 2 + }, + "end": { + "line": 41, + "column": 7 + } + }, + "expression": { + "type": "MemberExpression", + "start": 463, + "end": 482, + "loc": { + "start": { + "line": 40, + "column": 2 + }, + "end": { + "line": 41, + "column": 6 + } + }, + "object": { + "type": "StringLiteral", + "start": 463, + "end": 475, + "loc": { + "start": { + "line": 40, + "column": 2 + }, + "end": { + "line": 40, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "property": { + "type": "Identifier", + "start": 479, + "end": 482, + "loc": { + "start": { + "line": 41, + "column": 3 + }, + "end": { + "line": 41, + "column": 6 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false + } + }, + { + "type": "ExpressionStatement", + "start": 486, + "end": 491, + "loc": { + "start": { + "line": 42, + "column": 2 + }, + "end": { + "line": 42, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 486, + "end": 490, + "loc": { + "start": { + "line": 42, + "column": 2 + }, + "end": { + "line": 42, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 495, + "end": 542, + "loc": { + "start": { + "line": 45, + "column": 0 + }, + "end": { + "line": 49, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 504, + "end": 505, + "loc": { + "start": { + "line": 45, + "column": 9 + }, + "end": { + "line": 45, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 507, + "end": 542, + "loc": { + "start": { + "line": 45, + "column": 12 + }, + "end": { + "line": 49, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 511, + "end": 532, + "loc": { + "start": { + "line": 46, + "column": 2 + }, + "end": { + "line": 47, + "column": 8 + } + }, + "expression": { + "type": "MemberExpression", + "start": 511, + "end": 531, + "loc": { + "start": { + "line": 46, + "column": 2 + }, + "end": { + "line": 47, + "column": 7 + } + }, + "object": { + "type": "StringLiteral", + "start": 511, + "end": 523, + "loc": { + "start": { + "line": 46, + "column": 2 + }, + "end": { + "line": 46, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "property": { + "type": "Identifier", + "start": 527, + "end": 530, + "loc": { + "start": { + "line": 47, + "column": 3 + }, + "end": { + "line": 47, + "column": 6 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": true + } + }, + { + "type": "ExpressionStatement", + "start": 535, + "end": 540, + "loc": { + "start": { + "line": 48, + "column": 2 + }, + "end": { + "line": 48, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 535, + "end": 539, + "loc": { + "start": { + "line": 48, + "column": 2 + }, + "end": { + "line": 48, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 544, + "end": 591, + "loc": { + "start": { + "line": 51, + "column": 0 + }, + "end": { + "line": 55, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 553, + "end": 554, + "loc": { + "start": { + "line": 51, + "column": 9 + }, + "end": { + "line": 51, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 556, + "end": 591, + "loc": { + "start": { + "line": 51, + "column": 12 + }, + "end": { + "line": 55, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 560, + "end": 581, + "loc": { + "start": { + "line": 52, + "column": 2 + }, + "end": { + "line": 53, + "column": 8 + } + }, + "expression": { + "type": "TaggedTemplateExpression", + "start": 560, + "end": 580, + "loc": { + "start": { + "line": 52, + "column": 2 + }, + "end": { + "line": 53, + "column": 7 + } + }, + "tag": { + "type": "StringLiteral", + "start": 560, + "end": 572, + "loc": { + "start": { + "line": 52, + "column": 2 + }, + "end": { + "line": 52, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "quasi": { + "type": "TemplateLiteral", + "start": 575, + "end": 580, + "loc": { + "start": { + "line": 53, + "column": 2 + }, + "end": { + "line": 53, + "column": 7 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 576, + "end": 579, + "loc": { + "start": { + "line": 53, + "column": 3 + }, + "end": { + "line": 53, + "column": 6 + } + }, + "value": { + "raw": "foo", + "cooked": "foo" + }, + "tail": true + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start": 584, + "end": 589, + "loc": { + "start": { + "line": 54, + "column": 2 + }, + "end": { + "line": 54, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 584, + "end": 588, + "loc": { + "start": { + "line": 54, + "column": 2 + }, + "end": { + "line": 54, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 593, + "end": 640, + "loc": { + "start": { + "line": 57, + "column": 0 + }, + "end": { + "line": 61, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 602, + "end": 603, + "loc": { + "start": { + "line": 57, + "column": 9 + }, + "end": { + "line": 57, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 605, + "end": 640, + "loc": { + "start": { + "line": 57, + "column": 12 + }, + "end": { + "line": 61, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 609, + "end": 630, + "loc": { + "start": { + "line": 58, + "column": 2 + }, + "end": { + "line": 59, + "column": 8 + } + }, + "expression": { + "type": "CallExpression", + "start": 609, + "end": 629, + "loc": { + "start": { + "line": 58, + "column": 2 + }, + "end": { + "line": 59, + "column": 7 + } + }, + "callee": { + "type": "StringLiteral", + "start": 609, + "end": 621, + "loc": { + "start": { + "line": 58, + "column": 2 + }, + "end": { + "line": 58, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "arguments": [ + { + "type": "Identifier", + "start": 625, + "end": 628, + "loc": { + "start": { + "line": 59, + "column": 3 + }, + "end": { + "line": 59, + "column": 6 + }, + "identifierName": "foo" + }, + "name": "foo" + } + ] + } + }, + { + "type": "ExpressionStatement", + "start": 633, + "end": 638, + "loc": { + "start": { + "line": 60, + "column": 2 + }, + "end": { + "line": 60, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 633, + "end": 637, + "loc": { + "start": { + "line": 60, + "column": 2 + }, + "end": { + "line": 60, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 642, + "end": 694, + "loc": { + "start": { + "line": 63, + "column": 0 + }, + "end": { + "line": 67, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 651, + "end": 652, + "loc": { + "start": { + "line": 63, + "column": 9 + }, + "end": { + "line": 63, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 654, + "end": 694, + "loc": { + "start": { + "line": 63, + "column": 12 + }, + "end": { + "line": 67, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 658, + "end": 664, + "loc": { + "start": { + "line": 64, + "column": 2 + }, + "end": { + "line": 64, + "column": 8 + } + }, + "expression": { + "type": "CallExpression", + "start": 658, + "end": 663, + "loc": { + "start": { + "line": 64, + "column": 2 + }, + "end": { + "line": 64, + "column": 7 + } + }, + "callee": { + "type": "Identifier", + "start": 658, + "end": 661, + "loc": { + "start": { + "line": 64, + "column": 2 + }, + "end": { + "line": 64, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + }, + { + "type": "ExpressionStatement", + "start": 667, + "end": 684, + "loc": { + "start": { + "line": 65, + "column": 2 + }, + "end": { + "line": 65, + "column": 19 + } + }, + "expression": { + "type": "MemberExpression", + "start": 667, + "end": 683, + "loc": { + "start": { + "line": 65, + "column": 2 + }, + "end": { + "line": 65, + "column": 18 + } + }, + "object": { + "type": "StringLiteral", + "start": 667, + "end": 679, + "loc": { + "start": { + "line": 65, + "column": 2 + }, + "end": { + "line": 65, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "property": { + "type": "Identifier", + "start": 680, + "end": 683, + "loc": { + "start": { + "line": 65, + "column": 15 + }, + "end": { + "line": 65, + "column": 18 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": false + } + }, + { + "type": "ExpressionStatement", + "start": 687, + "end": 692, + "loc": { + "start": { + "line": 66, + "column": 2 + }, + "end": { + "line": 66, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 687, + "end": 691, + "loc": { + "start": { + "line": 66, + "column": 2 + }, + "end": { + "line": 66, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 696, + "end": 749, + "loc": { + "start": { + "line": 69, + "column": 0 + }, + "end": { + "line": 73, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 705, + "end": 706, + "loc": { + "start": { + "line": 69, + "column": 9 + }, + "end": { + "line": 69, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 708, + "end": 749, + "loc": { + "start": { + "line": 69, + "column": 12 + }, + "end": { + "line": 73, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 712, + "end": 718, + "loc": { + "start": { + "line": 70, + "column": 2 + }, + "end": { + "line": 70, + "column": 8 + } + }, + "expression": { + "type": "CallExpression", + "start": 712, + "end": 717, + "loc": { + "start": { + "line": 70, + "column": 2 + }, + "end": { + "line": 70, + "column": 7 + } + }, + "callee": { + "type": "Identifier", + "start": 712, + "end": 715, + "loc": { + "start": { + "line": 70, + "column": 2 + }, + "end": { + "line": 70, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + }, + { + "type": "ExpressionStatement", + "start": 721, + "end": 739, + "loc": { + "start": { + "line": 71, + "column": 2 + }, + "end": { + "line": 71, + "column": 20 + } + }, + "expression": { + "type": "MemberExpression", + "start": 721, + "end": 738, + "loc": { + "start": { + "line": 71, + "column": 2 + }, + "end": { + "line": 71, + "column": 19 + } + }, + "object": { + "type": "StringLiteral", + "start": 721, + "end": 733, + "loc": { + "start": { + "line": 71, + "column": 2 + }, + "end": { + "line": 71, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "property": { + "type": "Identifier", + "start": 734, + "end": 737, + "loc": { + "start": { + "line": 71, + "column": 15 + }, + "end": { + "line": 71, + "column": 18 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": true + } + }, + { + "type": "ExpressionStatement", + "start": 742, + "end": 747, + "loc": { + "start": { + "line": 72, + "column": 2 + }, + "end": { + "line": 72, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 742, + "end": 746, + "loc": { + "start": { + "line": 72, + "column": 2 + }, + "end": { + "line": 72, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 751, + "end": 804, + "loc": { + "start": { + "line": 75, + "column": 0 + }, + "end": { + "line": 79, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 760, + "end": 761, + "loc": { + "start": { + "line": 75, + "column": 9 + }, + "end": { + "line": 75, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 763, + "end": 804, + "loc": { + "start": { + "line": 75, + "column": 12 + }, + "end": { + "line": 79, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 767, + "end": 773, + "loc": { + "start": { + "line": 76, + "column": 2 + }, + "end": { + "line": 76, + "column": 8 + } + }, + "expression": { + "type": "CallExpression", + "start": 767, + "end": 772, + "loc": { + "start": { + "line": 76, + "column": 2 + }, + "end": { + "line": 76, + "column": 7 + } + }, + "callee": { + "type": "Identifier", + "start": 767, + "end": 770, + "loc": { + "start": { + "line": 76, + "column": 2 + }, + "end": { + "line": 76, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + }, + { + "type": "ExpressionStatement", + "start": 776, + "end": 794, + "loc": { + "start": { + "line": 77, + "column": 2 + }, + "end": { + "line": 77, + "column": 20 + } + }, + "expression": { + "type": "TaggedTemplateExpression", + "start": 776, + "end": 793, + "loc": { + "start": { + "line": 77, + "column": 2 + }, + "end": { + "line": 77, + "column": 19 + } + }, + "tag": { + "type": "StringLiteral", + "start": 776, + "end": 788, + "loc": { + "start": { + "line": 77, + "column": 2 + }, + "end": { + "line": 77, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "quasi": { + "type": "TemplateLiteral", + "start": 788, + "end": 793, + "loc": { + "start": { + "line": 77, + "column": 14 + }, + "end": { + "line": 77, + "column": 19 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 789, + "end": 792, + "loc": { + "start": { + "line": 77, + "column": 15 + }, + "end": { + "line": 77, + "column": 18 + } + }, + "value": { + "raw": "bar", + "cooked": "bar" + }, + "tail": true + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start": 797, + "end": 802, + "loc": { + "start": { + "line": 78, + "column": 2 + }, + "end": { + "line": 78, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 797, + "end": 801, + "loc": { + "start": { + "line": 78, + "column": 2 + }, + "end": { + "line": 78, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 806, + "end": 859, + "loc": { + "start": { + "line": 81, + "column": 0 + }, + "end": { + "line": 85, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 815, + "end": 816, + "loc": { + "start": { + "line": 81, + "column": 9 + }, + "end": { + "line": 81, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 818, + "end": 859, + "loc": { + "start": { + "line": 81, + "column": 12 + }, + "end": { + "line": 85, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 822, + "end": 828, + "loc": { + "start": { + "line": 82, + "column": 2 + }, + "end": { + "line": 82, + "column": 8 + } + }, + "expression": { + "type": "CallExpression", + "start": 822, + "end": 827, + "loc": { + "start": { + "line": 82, + "column": 2 + }, + "end": { + "line": 82, + "column": 7 + } + }, + "callee": { + "type": "Identifier", + "start": 822, + "end": 825, + "loc": { + "start": { + "line": 82, + "column": 2 + }, + "end": { + "line": 82, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + }, + { + "type": "ExpressionStatement", + "start": 831, + "end": 849, + "loc": { + "start": { + "line": 83, + "column": 2 + }, + "end": { + "line": 83, + "column": 20 + } + }, + "expression": { + "type": "CallExpression", + "start": 831, + "end": 848, + "loc": { + "start": { + "line": 83, + "column": 2 + }, + "end": { + "line": 83, + "column": 19 + } + }, + "callee": { + "type": "StringLiteral", + "start": 831, + "end": 843, + "loc": { + "start": { + "line": 83, + "column": 2 + }, + "end": { + "line": 83, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "arguments": [ + { + "type": "Identifier", + "start": 844, + "end": 847, + "loc": { + "start": { + "line": 83, + "column": 15 + }, + "end": { + "line": 83, + "column": 18 + }, + "identifierName": "bar" + }, + "name": "bar" + } + ] + } + }, + { + "type": "ExpressionStatement", + "start": 852, + "end": 857, + "loc": { + "start": { + "line": 84, + "column": 2 + }, + "end": { + "line": 84, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 852, + "end": 856, + "loc": { + "start": { + "line": 84, + "column": 2 + }, + "end": { + "line": 84, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 861, + "end": 916, + "loc": { + "start": { + "line": 87, + "column": 0 + }, + "end": { + "line": 92, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 870, + "end": 871, + "loc": { + "start": { + "line": 87, + "column": 9 + }, + "end": { + "line": 87, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 873, + "end": 916, + "loc": { + "start": { + "line": 87, + "column": 12 + }, + "end": { + "line": 92, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 877, + "end": 883, + "loc": { + "start": { + "line": 88, + "column": 2 + }, + "end": { + "line": 88, + "column": 8 + } + }, + "expression": { + "type": "CallExpression", + "start": 877, + "end": 882, + "loc": { + "start": { + "line": 88, + "column": 2 + }, + "end": { + "line": 88, + "column": 7 + } + }, + "callee": { + "type": "Identifier", + "start": 877, + "end": 880, + "loc": { + "start": { + "line": 88, + "column": 2 + }, + "end": { + "line": 88, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + }, + { + "type": "ExpressionStatement", + "start": 886, + "end": 906, + "loc": { + "start": { + "line": 89, + "column": 2 + }, + "end": { + "line": 90, + "column": 7 + } + }, + "expression": { + "type": "MemberExpression", + "start": 886, + "end": 905, + "loc": { + "start": { + "line": 89, + "column": 2 + }, + "end": { + "line": 90, + "column": 6 + } + }, + "object": { + "type": "StringLiteral", + "start": 886, + "end": 898, + "loc": { + "start": { + "line": 89, + "column": 2 + }, + "end": { + "line": 89, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "property": { + "type": "Identifier", + "start": 902, + "end": 905, + "loc": { + "start": { + "line": 90, + "column": 3 + }, + "end": { + "line": 90, + "column": 6 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": false + } + }, + { + "type": "ExpressionStatement", + "start": 909, + "end": 914, + "loc": { + "start": { + "line": 91, + "column": 2 + }, + "end": { + "line": 91, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 909, + "end": 913, + "loc": { + "start": { + "line": 91, + "column": 2 + }, + "end": { + "line": 91, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 918, + "end": 974, + "loc": { + "start": { + "line": 94, + "column": 0 + }, + "end": { + "line": 99, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 927, + "end": 928, + "loc": { + "start": { + "line": 94, + "column": 9 + }, + "end": { + "line": 94, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 930, + "end": 974, + "loc": { + "start": { + "line": 94, + "column": 12 + }, + "end": { + "line": 99, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 934, + "end": 940, + "loc": { + "start": { + "line": 95, + "column": 2 + }, + "end": { + "line": 95, + "column": 8 + } + }, + "expression": { + "type": "CallExpression", + "start": 934, + "end": 939, + "loc": { + "start": { + "line": 95, + "column": 2 + }, + "end": { + "line": 95, + "column": 7 + } + }, + "callee": { + "type": "Identifier", + "start": 934, + "end": 937, + "loc": { + "start": { + "line": 95, + "column": 2 + }, + "end": { + "line": 95, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + }, + { + "type": "ExpressionStatement", + "start": 943, + "end": 964, + "loc": { + "start": { + "line": 96, + "column": 2 + }, + "end": { + "line": 97, + "column": 8 + } + }, + "expression": { + "type": "MemberExpression", + "start": 943, + "end": 963, + "loc": { + "start": { + "line": 96, + "column": 2 + }, + "end": { + "line": 97, + "column": 7 + } + }, + "object": { + "type": "StringLiteral", + "start": 943, + "end": 955, + "loc": { + "start": { + "line": 96, + "column": 2 + }, + "end": { + "line": 96, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "property": { + "type": "Identifier", + "start": 959, + "end": 962, + "loc": { + "start": { + "line": 97, + "column": 3 + }, + "end": { + "line": 97, + "column": 6 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": true + } + }, + { + "type": "ExpressionStatement", + "start": 967, + "end": 972, + "loc": { + "start": { + "line": 98, + "column": 2 + }, + "end": { + "line": 98, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 967, + "end": 971, + "loc": { + "start": { + "line": 98, + "column": 2 + }, + "end": { + "line": 98, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 976, + "end": 1032, + "loc": { + "start": { + "line": 101, + "column": 0 + }, + "end": { + "line": 106, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 985, + "end": 986, + "loc": { + "start": { + "line": 101, + "column": 9 + }, + "end": { + "line": 101, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 988, + "end": 1032, + "loc": { + "start": { + "line": 101, + "column": 12 + }, + "end": { + "line": 106, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 992, + "end": 998, + "loc": { + "start": { + "line": 102, + "column": 2 + }, + "end": { + "line": 102, + "column": 8 + } + }, + "expression": { + "type": "CallExpression", + "start": 992, + "end": 997, + "loc": { + "start": { + "line": 102, + "column": 2 + }, + "end": { + "line": 102, + "column": 7 + } + }, + "callee": { + "type": "Identifier", + "start": 992, + "end": 995, + "loc": { + "start": { + "line": 102, + "column": 2 + }, + "end": { + "line": 102, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + }, + { + "type": "ExpressionStatement", + "start": 1001, + "end": 1022, + "loc": { + "start": { + "line": 103, + "column": 2 + }, + "end": { + "line": 104, + "column": 8 + } + }, + "expression": { + "type": "TaggedTemplateExpression", + "start": 1001, + "end": 1021, + "loc": { + "start": { + "line": 103, + "column": 2 + }, + "end": { + "line": 104, + "column": 7 + } + }, + "tag": { + "type": "StringLiteral", + "start": 1001, + "end": 1013, + "loc": { + "start": { + "line": 103, + "column": 2 + }, + "end": { + "line": 103, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "quasi": { + "type": "TemplateLiteral", + "start": 1016, + "end": 1021, + "loc": { + "start": { + "line": 104, + "column": 2 + }, + "end": { + "line": 104, + "column": 7 + } + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "start": 1017, + "end": 1020, + "loc": { + "start": { + "line": 104, + "column": 3 + }, + "end": { + "line": 104, + "column": 6 + } + }, + "value": { + "raw": "bar", + "cooked": "bar" + }, + "tail": true + } + ] + } + } + }, + { + "type": "ExpressionStatement", + "start": 1025, + "end": 1030, + "loc": { + "start": { + "line": 105, + "column": 2 + }, + "end": { + "line": 105, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 1025, + "end": 1029, + "loc": { + "start": { + "line": 105, + "column": 2 + }, + "end": { + "line": 105, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 1034, + "end": 1090, + "loc": { + "start": { + "line": 108, + "column": 0 + }, + "end": { + "line": 113, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 1043, + "end": 1044, + "loc": { + "start": { + "line": 108, + "column": 9 + }, + "end": { + "line": 108, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 1046, + "end": 1090, + "loc": { + "start": { + "line": 108, + "column": 12 + }, + "end": { + "line": 113, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1050, + "end": 1056, + "loc": { + "start": { + "line": 109, + "column": 2 + }, + "end": { + "line": 109, + "column": 8 + } + }, + "expression": { + "type": "CallExpression", + "start": 1050, + "end": 1055, + "loc": { + "start": { + "line": 109, + "column": 2 + }, + "end": { + "line": 109, + "column": 7 + } + }, + "callee": { + "type": "Identifier", + "start": 1050, + "end": 1053, + "loc": { + "start": { + "line": 109, + "column": 2 + }, + "end": { + "line": 109, + "column": 5 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [] + } + }, + { + "type": "ExpressionStatement", + "start": 1059, + "end": 1080, + "loc": { + "start": { + "line": 110, + "column": 2 + }, + "end": { + "line": 111, + "column": 8 + } + }, + "expression": { + "type": "CallExpression", + "start": 1059, + "end": 1079, + "loc": { + "start": { + "line": 110, + "column": 2 + }, + "end": { + "line": 111, + "column": 7 + } + }, + "callee": { + "type": "StringLiteral", + "start": 1059, + "end": 1071, + "loc": { + "start": { + "line": 110, + "column": 2 + }, + "end": { + "line": 110, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + }, + "arguments": [ + { + "type": "Identifier", + "start": 1075, + "end": 1078, + "loc": { + "start": { + "line": 111, + "column": 3 + }, + "end": { + "line": 111, + "column": 6 + }, + "identifierName": "bar" + }, + "name": "bar" + } + ] + } + }, + { + "type": "ExpressionStatement", + "start": 1083, + "end": 1088, + "loc": { + "start": { + "line": 112, + "column": 2 + }, + "end": { + "line": 112, + "column": 7 + } + }, + "expression": { + "type": "StringLiteral", + "start": 1083, + "end": 1087, + "loc": { + "start": { + "line": 112, + "column": 2 + }, + "end": { + "line": 112, + "column": 6 + } + }, + "extra": { + "rawValue": "\u0005", + "raw": "\"\\5\"" + }, + "value": "\u0005" + } + } + ], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 1092, + "end": 1129, + "loc": { + "start": { + "line": 115, + "column": 0 + }, + "end": { + "line": 118, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 1101, + "end": 1102, + "loc": { + "start": { + "line": 115, + "column": 9 + }, + "end": { + "line": 115, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 1104, + "end": 1129, + "loc": { + "start": { + "line": 115, + "column": 12 + }, + "end": { + "line": 118, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 1108, + "end": 1111, + "loc": { + "start": { + "line": 116, + "column": 2 + }, + "end": { + "line": 116, + "column": 5 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 1108, + "end": 1110, + "loc": { + "start": { + "line": 116, + "column": 2 + }, + "end": { + "line": 116, + "column": 4 + } + }, + "extra": { + "rawValue": 5, + "raw": "05" + }, + "value": 5 + } + }, + { + "type": "ExpressionStatement", + "start": 1114, + "end": 1127, + "loc": { + "start": { + "line": 117, + "column": 2 + }, + "end": { + "line": 117, + "column": 15 + } + }, + "expression": { + "type": "StringLiteral", + "start": 1114, + "end": 1126, + "loc": { + "start": { + "line": 117, + "column": 2 + }, + "end": { + "line": 117, + "column": 14 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "\"use strict\"" + }, + "value": "use strict" + } + } + ], + "directives": [] } } ], "directives": [] - } + }, + "comments": [ + { + "type": "CommentLine", + "value": " Should not be a syntax error because should not be parsed in strict mode.", + "start": 180, + "end": 256, + "loc": { + "start": { + "line": 16, + "column": 0 + }, + "end": { + "line": 16, + "column": 76 + } + } + } + ] } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive-function/input.js b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive-function/input.js new file mode 100644 index 0000000000..ff2a818984 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive-function/input.js @@ -0,0 +1,32 @@ +function a() { + "\5"; + "use strict"; +} + +function b() { + "\4"; + "\5"; + "use strict"; +} + +function c() { + "use strict"; + "\5"; +} + +function d() { + "use strict"; + "\4"; + "\5"; +} + +function c() { + "use strict"; + 05; +} + +function d() { + "use strict"; + 04; + 05; +} diff --git a/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive-function/options.json b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive-function/options.json new file mode 100644 index 0000000000..b412ffe671 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive-function/options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "script" +} diff --git a/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive-function/output.json b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive-function/output.json new file mode 100644 index 0000000000..a0c9784b85 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive-function/output.json @@ -0,0 +1,891 @@ +{ + "type": "File", + "start": 0, + "end": 268, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 32, + "column": 1 + } + }, + "errors": [ + "SyntaxError: Octal literal in strict mode (2:4)", + "SyntaxError: Octal literal in strict mode (7:4)", + "SyntaxError: Octal literal in strict mode (8:4)", + "SyntaxError: Octal literal in strict mode (14:4)", + "SyntaxError: Octal literal in strict mode (19:4)", + "SyntaxError: Octal literal in strict mode (20:4)", + "SyntaxError: Octal literal in strict mode (25:2)", + "SyntaxError: Octal literal in strict mode (30:2)", + "SyntaxError: Octal literal in strict mode (31:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 268, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 32, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 17, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 17, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": "\\5", + "extra": { + "raw": "\"\\5\"", + "rawValue": "\\5" + } + } + }, + { + "type": "Directive", + "start": 25, + "end": 38, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 25, + "end": 37, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + }, + { + "type": "FunctionDeclaration", + "start": 42, + "end": 90, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 10, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 51, + "end": 52, + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + }, + "identifierName": "b" + }, + "name": "b" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 55, + "end": 90, + "loc": { + "start": { + "line": 6, + "column": 13 + }, + "end": { + "line": 10, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 59, + "end": 64, + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 59, + "end": 63, + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 6 + } + }, + "value": "\\4", + "extra": { + "raw": "\"\\4\"", + "rawValue": "\\4" + } + } + }, + { + "type": "Directive", + "start": 67, + "end": 72, + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 67, + "end": 71, + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 6 + } + }, + "value": "\\5", + "extra": { + "raw": "\"\\5\"", + "rawValue": "\\5" + } + } + }, + { + "type": "Directive", + "start": 75, + "end": 88, + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 75, + "end": 87, + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + }, + { + "type": "FunctionDeclaration", + "start": 92, + "end": 132, + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 15, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 101, + "end": 102, + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 12, + "column": 10 + }, + "identifierName": "c" + }, + "name": "c" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 105, + "end": 132, + "loc": { + "start": { + "line": 12, + "column": 13 + }, + "end": { + "line": 15, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 109, + "end": 122, + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 13, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 109, + "end": 121, + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 13, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + }, + { + "type": "Directive", + "start": 125, + "end": 130, + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 7 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 125, + "end": 129, + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 6 + } + }, + "value": "\\5", + "extra": { + "raw": "\"\\5\"", + "rawValue": "\\5" + } + } + } + ] + } + }, + { + "type": "FunctionDeclaration", + "start": 134, + "end": 182, + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 21, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 143, + "end": 144, + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 10 + }, + "identifierName": "d" + }, + "name": "d" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 147, + "end": 182, + "loc": { + "start": { + "line": 17, + "column": 13 + }, + "end": { + "line": 21, + "column": 1 + } + }, + "body": [], + "directives": [ + { + "type": "Directive", + "start": 151, + "end": 164, + "loc": { + "start": { + "line": 18, + "column": 2 + }, + "end": { + "line": 18, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 151, + "end": 163, + "loc": { + "start": { + "line": 18, + "column": 2 + }, + "end": { + "line": 18, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + }, + { + "type": "Directive", + "start": 167, + "end": 172, + "loc": { + "start": { + "line": 19, + "column": 2 + }, + "end": { + "line": 19, + "column": 7 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 167, + "end": 171, + "loc": { + "start": { + "line": 19, + "column": 2 + }, + "end": { + "line": 19, + "column": 6 + } + }, + "value": "\\4", + "extra": { + "raw": "\"\\4\"", + "rawValue": "\\4" + } + } + }, + { + "type": "Directive", + "start": 175, + "end": 180, + "loc": { + "start": { + "line": 20, + "column": 2 + }, + "end": { + "line": 20, + "column": 7 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 175, + "end": 179, + "loc": { + "start": { + "line": 20, + "column": 2 + }, + "end": { + "line": 20, + "column": 6 + } + }, + "value": "\\5", + "extra": { + "raw": "\"\\5\"", + "rawValue": "\\5" + } + } + } + ] + } + }, + { + "type": "FunctionDeclaration", + "start": 184, + "end": 222, + "loc": { + "start": { + "line": 23, + "column": 0 + }, + "end": { + "line": 26, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 193, + "end": 194, + "loc": { + "start": { + "line": 23, + "column": 9 + }, + "end": { + "line": 23, + "column": 10 + }, + "identifierName": "c" + }, + "name": "c" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 197, + "end": 222, + "loc": { + "start": { + "line": 23, + "column": 13 + }, + "end": { + "line": 26, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 217, + "end": 220, + "loc": { + "start": { + "line": 25, + "column": 2 + }, + "end": { + "line": 25, + "column": 5 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 217, + "end": 219, + "loc": { + "start": { + "line": 25, + "column": 2 + }, + "end": { + "line": 25, + "column": 4 + } + }, + "extra": { + "rawValue": 5, + "raw": "05" + }, + "value": 5 + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 201, + "end": 214, + "loc": { + "start": { + "line": 24, + "column": 2 + }, + "end": { + "line": 24, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 201, + "end": 213, + "loc": { + "start": { + "line": 24, + "column": 2 + }, + "end": { + "line": 24, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + }, + { + "type": "FunctionDeclaration", + "start": 224, + "end": 268, + "loc": { + "start": { + "line": 28, + "column": 0 + }, + "end": { + "line": 32, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 233, + "end": 234, + "loc": { + "start": { + "line": 28, + "column": 9 + }, + "end": { + "line": 28, + "column": 10 + }, + "identifierName": "d" + }, + "name": "d" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 237, + "end": 268, + "loc": { + "start": { + "line": 28, + "column": 13 + }, + "end": { + "line": 32, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 257, + "end": 260, + "loc": { + "start": { + "line": 30, + "column": 2 + }, + "end": { + "line": 30, + "column": 5 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 257, + "end": 259, + "loc": { + "start": { + "line": 30, + "column": 2 + }, + "end": { + "line": 30, + "column": 4 + } + }, + "extra": { + "rawValue": 4, + "raw": "04" + }, + "value": 4 + } + }, + { + "type": "ExpressionStatement", + "start": 263, + "end": 266, + "loc": { + "start": { + "line": 31, + "column": 2 + }, + "end": { + "line": 31, + "column": 5 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 263, + "end": 265, + "loc": { + "start": { + "line": 31, + "column": 2 + }, + "end": { + "line": 31, + "column": 4 + } + }, + "extra": { + "rawValue": 5, + "raw": "05" + }, + "value": 5 + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 241, + "end": 254, + "loc": { + "start": { + "line": 29, + "column": 2 + }, + "end": { + "line": 29, + "column": 15 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 241, + "end": 253, + "loc": { + "start": { + "line": 29, + "column": 2 + }, + "end": { + "line": 29, + "column": 14 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive/input.js b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive/input.js new file mode 100644 index 0000000000..ee60917379 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive/input.js @@ -0,0 +1,14 @@ +"\01 foo \02 bar \03"; + +"\4"; +"\5"; + +"use strict"; + +"\4"; +"\5"; + +04; +05; + +"\04 foo \05 bar \06"; diff --git a/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive/output.json b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive/output.json new file mode 100644 index 0000000000..a82b9fedbf --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/regression/invalid-octal-strict-directive/output.json @@ -0,0 +1,365 @@ +{ + "type": "File", + "start": 0, + "end": 96, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 14, + "column": 22 + } + }, + "errors": [ + "SyntaxError: Octal literal in strict mode (8:2)", + "SyntaxError: Octal literal in strict mode (9:2)", + "SyntaxError: Octal literal in strict mode (11:0)", + "SyntaxError: Octal literal in strict mode (12:0)", + "SyntaxError: Octal literal in strict mode (14:2)", + "SyntaxError: Octal literal in strict mode (14:10)", + "SyntaxError: Octal literal in strict mode (14:18)", + "SyntaxError: Octal literal in strict mode (1:2)", + "SyntaxError: Octal literal in strict mode (1:10)", + "SyntaxError: Octal literal in strict mode (1:18)", + "SyntaxError: Octal literal in strict mode (3:2)", + "SyntaxError: Octal literal in strict mode (4:2)" + ], + "program": { + "type": "Program", + "start": 0, + "end": 96, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 14, + "column": 22 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 65, + "end": 68, + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 65, + "end": 67, + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 2 + } + }, + "extra": { + "rawValue": 4, + "raw": "04" + }, + "value": 4 + } + }, + { + "type": "ExpressionStatement", + "start": 69, + "end": 72, + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 3 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 69, + "end": 71, + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 2 + } + }, + "extra": { + "rawValue": 5, + "raw": "05" + }, + "value": 5 + } + }, + { + "type": "ExpressionStatement", + "start": 74, + "end": 96, + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 22 + } + }, + "expression": { + "type": "StringLiteral", + "start": 74, + "end": 95, + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 21 + } + }, + "extra": { + "rawValue": "\u0004 foo \u0005 bar \u0006", + "raw": "\"\\04 foo \\05 bar \\06\"" + }, + "value": "\u0004 foo \u0005 bar \u0006" + } + } + ], + "directives": [ + { + "type": "Directive", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "value": "\\01 foo \\02 bar \\03", + "extra": { + "raw": "\"\\01 foo \\02 bar \\03\"", + "rawValue": "\\01 foo \\02 bar \\03" + } + } + }, + { + "type": "Directive", + "start": 24, + "end": 29, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 5 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 24, + "end": 28, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\\4", + "extra": { + "raw": "\"\\4\"", + "rawValue": "\\4" + } + } + }, + { + "type": "Directive", + "start": 30, + "end": 35, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 30, + "end": 34, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "value": "\\5", + "extra": { + "raw": "\"\\5\"", + "rawValue": "\\5" + } + } + }, + { + "type": "Directive", + "start": 37, + "end": 50, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 13 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 37, + "end": 49, + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": "use strict", + "extra": { + "raw": "\"use strict\"", + "rawValue": "use strict" + } + } + }, + { + "type": "Directive", + "start": 52, + "end": 57, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 5 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 52, + "end": 56, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "value": "\\4", + "extra": { + "raw": "\"\\4\"", + "rawValue": "\\4" + } + } + }, + { + "type": "Directive", + "start": 58, + "end": 63, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 5 + } + }, + "value": { + "type": "DirectiveLiteral", + "start": 58, + "end": 62, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 4 + } + }, + "value": "\\5", + "extra": { + "raw": "\"\\5\"", + "rawValue": "\\5" + } + } + } + ] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/output.json b/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/output.json index 99253558c8..bda3123004 100644 --- a/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/output.json +++ b/packages/babel-parser/test/fixtures/core/regression/non-octal-float-strict-mode/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Legacy octal literals are not allowed in strict mode (1:0)" + "SyntaxError: Octal literal in strict mode (1:0)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/499/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/499/output.json index 1504ace4ac..828fbbd75f 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/499/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/499/output.json @@ -13,7 +13,6 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:35)", "SyntaxError: Octal literal in strict mode (1:35)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json index 805c176e78..f5ab6e0fd0 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/500/output.json @@ -13,8 +13,7 @@ } }, "errors": [ - "SyntaxError: Legacy octal literals are not allowed in strict mode (1:33)", - "SyntaxError: Legacy octal literals are not allowed in strict mode (1:33)" + "SyntaxError: Octal literal in strict mode (1:33)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/502/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/502/output.json index 5eb3bcef0b..9da2955ced 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/502/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/502/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Legacy octal literals are not allowed in strict mode (1:36)" + "SyntaxError: Octal literal in strict mode (1:36)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/522/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/522/output.json index 98d2e05271..ebcddc617e 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/522/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/522/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Legacy octal literals are not allowed in strict mode (1:65)" + "SyntaxError: Octal literal in strict mode (1:65)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/550/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/550/output.json index 9b383cded8..592b89bb27 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/550/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/550/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Legacy octal literals are not allowed in strict mode (2:10)" + "SyntaxError: Octal literal in strict mode (2:10)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/552/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/552/output.json index a7d3e10860..4036096368 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/552/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/552/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Legacy octal literals are not allowed in strict mode (2:10)" + "SyntaxError: Octal literal in strict mode (2:10)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/249/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/249/output.json index 18c0889f74..e964667083 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/249/output.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/249/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Legacy octal literals are not allowed in strict mode (1:21)" + "SyntaxError: Octal literal in strict mode (1:21)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/output.json index 18c0889f74..e964667083 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0094/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Legacy octal literals are not allowed in strict mode (1:21)" + "SyntaxError: Octal literal in strict mode (1:21)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/output.json index 1504ace4ac..828fbbd75f 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0217/output.json @@ -13,7 +13,6 @@ } }, "errors": [ - "SyntaxError: Octal literal in strict mode (1:35)", "SyntaxError: Octal literal in strict mode (1:35)" ], "program": { diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json index 805c176e78..f5ab6e0fd0 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0218/output.json @@ -13,8 +13,7 @@ } }, "errors": [ - "SyntaxError: Legacy octal literals are not allowed in strict mode (1:33)", - "SyntaxError: Legacy octal literals are not allowed in strict mode (1:33)" + "SyntaxError: Octal literal in strict mode (1:33)" ], "program": { "type": "Program", diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/output.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/output.json index 5eb3bcef0b..9da2955ced 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/output.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0220/output.json @@ -13,7 +13,7 @@ } }, "errors": [ - "SyntaxError: Legacy octal literals are not allowed in strict mode (1:36)" + "SyntaxError: Octal literal in strict mode (1:36)" ], "program": { "type": "Program",