diff --git a/packages/babel-generator/test/fixtures/flow/declare-exports/input.js b/packages/babel-generator/test/fixtures/flow/declare-exports/input.js index ea4a8c7cd4..279e6ab4f9 100644 --- a/packages/babel-generator/test/fixtures/flow/declare-exports/input.js +++ b/packages/babel-generator/test/fixtures/flow/declare-exports/input.js @@ -24,9 +24,9 @@ declare module B { } declare module "foo" { declare export type * from "bar"; } -declare export opaque type Foo; +declare export opaque type Foo1; declare export opaque type Bar; declare export opaque type Baz: Foo; -declare export opaque type Foo: Bar; -declare export opaque type Foo: Bar; -declare export opaque type Foo: Bar; +declare export opaque type Foo3: Bar; +declare export opaque type Foo4: Bar; +declare export opaque type Foo5: Bar; diff --git a/packages/babel-generator/test/fixtures/flow/declare-exports/output.js b/packages/babel-generator/test/fixtures/flow/declare-exports/output.js index da22c01415..877c430994 100644 --- a/packages/babel-generator/test/fixtures/flow/declare-exports/output.js +++ b/packages/babel-generator/test/fixtures/flow/declare-exports/output.js @@ -33,9 +33,9 @@ declare module B { declare module "foo" { declare export type * from "bar"; } -declare export opaque type Foo; +declare export opaque type Foo1; declare export opaque type Bar; declare export opaque type Baz: Foo; -declare export opaque type Foo: Bar; -declare export opaque type Foo: Bar; -declare export opaque type Foo: Bar; \ No newline at end of file +declare export opaque type Foo3: Bar; +declare export opaque type Foo4: Bar; +declare export opaque type Foo5: Bar; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/flow/def-site-variance/input.js b/packages/babel-generator/test/fixtures/flow/def-site-variance/input.js index 5cda68f8e9..9f00e80993 100644 --- a/packages/babel-generator/test/fixtures/flow/def-site-variance/input.js +++ b/packages/babel-generator/test/fixtures/flow/def-site-variance/input.js @@ -1,10 +1,10 @@ class C1<+T, -U> {} function f<+T, -U>() {} type T<+T, -U> = {}; -type T = { +p: T }; -type T = { -p: T }; -type T = { +[k:K]: V }; -type T = { -[k:K]: V }; +type T2 = { +p: T }; +type T3 = { -p: T }; +type T4 = { +[k:K]: V }; +type T5 = { -[k:K]: V }; interface I { +p: T } interface I { -p: T } interface I { +[k:K]: V } diff --git a/packages/babel-generator/test/fixtures/flow/def-site-variance/output.js b/packages/babel-generator/test/fixtures/flow/def-site-variance/output.js index e411f46461..5c2b69d1a6 100644 --- a/packages/babel-generator/test/fixtures/flow/def-site-variance/output.js +++ b/packages/babel-generator/test/fixtures/flow/def-site-variance/output.js @@ -3,16 +3,16 @@ class C1<+T, -U> {} function f<+T, -U>() {} type T<+T, -U> = {}; -type T = { +type T2 = { +p: T }; -type T = { +type T3 = { -p: T }; -type T = { +type T4 = { +[k: K]: V }; -type T = { +type T5 = { -[k: K]: V }; interface I { diff --git a/packages/babel-generator/test/fixtures/flow/internal-slot/input.js b/packages/babel-generator/test/fixtures/flow/internal-slot/input.js index 7888fc6cb4..b00d3bd76f 100644 --- a/packages/babel-generator/test/fixtures/flow/internal-slot/input.js +++ b/packages/babel-generator/test/fixtures/flow/internal-slot/input.js @@ -1,7 +1,7 @@ declare class C { static [[foo]]: T } declare class C { [[foo]]: T } -interface T { [[foo]]: X } -interface T { [[foo]](): X } -type T = { [[foo]]: X } -type T = { [[foo]](): X } -type T = { [[foo]]?: X } +interface I { [[foo]]: X } +interface I { [[foo]](): X } +type T1 = { [[foo]]: X } +type T2 = { [[foo]](): X } +type T3 = { [[foo]]?: X } diff --git a/packages/babel-generator/test/fixtures/flow/internal-slot/output.js b/packages/babel-generator/test/fixtures/flow/internal-slot/output.js index a8c375a2c4..2a48fb9f18 100644 --- a/packages/babel-generator/test/fixtures/flow/internal-slot/output.js +++ b/packages/babel-generator/test/fixtures/flow/internal-slot/output.js @@ -4,18 +4,18 @@ declare class C { declare class C { [[foo]]: T } -interface T { +interface I { [[foo]]: X } -interface T { +interface I { [[foo]]() => X } -type T = { +type T1 = { [[foo]]: X }; -type T = { +type T2 = { [[foo]]() => X }; -type T = { +type T3 = { [[foo]]?: X -}; +}; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/flow/object-literal-types/input.js b/packages/babel-generator/test/fixtures/flow/object-literal-types/input.js index 6d747ee65e..f3139a94e3 100644 --- a/packages/babel-generator/test/fixtures/flow/object-literal-types/input.js +++ b/packages/babel-generator/test/fixtures/flow/object-literal-types/input.js @@ -1,11 +1,11 @@ type U = {}; type V = {}; -type T = { ...U, }; -type T = { ...U, ...V }; -type T = { p: V, ...U }; -type T = { ...U, p: V, }; -type T = { ...{}|{ p: V, }}; -type T = { foo(): number } -type T = { foo: () => number } -type T = { [string]: U }; -type T = { [param: string]: U }; +type T1 = { ...U, }; +type T2 = { ...U, ...V }; +type T3 = { p: V, ...U }; +type T4 = { ...U, p: V, }; +type T5 = { ...{}|{ p: V, }}; +type T6 = { foo(): number } +type T7 = { foo: () => number } +type T8 = { [string]: U }; +type T9 = { [param: string]: U }; diff --git a/packages/babel-generator/test/fixtures/flow/object-literal-types/output.js b/packages/babel-generator/test/fixtures/flow/object-literal-types/output.js index 952f62e302..5c02e095e3 100644 --- a/packages/babel-generator/test/fixtures/flow/object-literal-types/output.js +++ b/packages/babel-generator/test/fixtures/flow/object-literal-types/output.js @@ -1,30 +1,30 @@ type U = {}; type V = {}; -type T = { ...U +type T1 = { ...U }; -type T = { ...U, +type T2 = { ...U, ...V, }; -type T = { +type T3 = { p: V, ...U, }; -type T = { ...U, +type T4 = { ...U, p: V, }; -type T = { ...{} | { +type T5 = { ...{} | { p: V } }; -type T = { +type T6 = { foo(): number }; -type T = { +type T7 = { foo: () => number }; -type T = { +type T8 = { [string]: U }; -type T = { +type T9 = { [param: string]: U }; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/flow/opaque-type-alias/input.js b/packages/babel-generator/test/fixtures/flow/opaque-type-alias/input.js index 1988fcaeed..3e77fce2b1 100644 --- a/packages/babel-generator/test/fixtures/flow/opaque-type-alias/input.js +++ b/packages/babel-generator/test/fixtures/flow/opaque-type-alias/input.js @@ -1,7 +1,7 @@ opaque type ID = string; opaque type Foo = Bar; opaque type Maybe = _Maybe; -export opaque type Foo = number; +export opaque type Foo2 = number; opaque type union = | {type: "A"} diff --git a/packages/babel-generator/test/fixtures/flow/opaque-type-alias/output.js b/packages/babel-generator/test/fixtures/flow/opaque-type-alias/output.js index b4f20f2d70..293f540109 100644 --- a/packages/babel-generator/test/fixtures/flow/opaque-type-alias/output.js +++ b/packages/babel-generator/test/fixtures/flow/opaque-type-alias/output.js @@ -1,7 +1,7 @@ opaque type ID = string; opaque type Foo = Bar; opaque type Maybe = _Maybe; -export opaque type Foo = number; +export opaque type Foo2 = number; opaque type union = { type: "A" } | { diff --git a/packages/babel-generator/test/fixtures/flow/type-alias/input.js b/packages/babel-generator/test/fixtures/flow/type-alias/input.js index f71342c526..c1d567e6df 100644 --- a/packages/babel-generator/test/fixtures/flow/type-alias/input.js +++ b/packages/babel-generator/test/fixtures/flow/type-alias/input.js @@ -1,7 +1,7 @@ type FBID = number; type Foo = Bar; type Maybe = _Maybe; -export type Foo = number; +export type Foo2 = number; type union = | {type: "A"} diff --git a/packages/babel-generator/test/fixtures/flow/type-alias/output.js b/packages/babel-generator/test/fixtures/flow/type-alias/output.js index a8263f6721..51933a7a77 100644 --- a/packages/babel-generator/test/fixtures/flow/type-alias/output.js +++ b/packages/babel-generator/test/fixtures/flow/type-alias/output.js @@ -1,7 +1,7 @@ type FBID = number; type Foo = Bar; type Maybe = _Maybe; -export type Foo = number; +export type Foo2 = number; type union = { type: "A" } | { diff --git a/packages/babel-parser/src/parser/base.js b/packages/babel-parser/src/parser/base.js index a56058c7c2..f071940233 100644 --- a/packages/babel-parser/src/parser/base.js +++ b/packages/babel-parser/src/parser/base.js @@ -3,11 +3,13 @@ import type { Options } from "../options"; import type State from "../tokenizer/state"; import type { PluginsMap } from "./index"; +import type ScopeHandler from "../util/scope"; export default class BaseParser { // Properties set by constructor in index.js options: Options; inModule: boolean; + scope: ScopeHandler; plugins: PluginsMap; filename: ?string; sawUnambiguousESM: boolean = false; diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 01f7dc03a2..f2bcfb19d3 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -29,10 +29,23 @@ import { } from "../util/identifier"; import type { Pos, Position } from "../util/location"; import * as charCodes from "charcodes"; +import { + BIND_OUTSIDE, + BIND_VAR, + functionFlags, + SCOPE_ARROW, + SCOPE_CLASS, + SCOPE_DIRECT_SUPER, + SCOPE_SUPER, + SCOPE_PROGRAM, +} from "../util/scopeflags"; export default class ExpressionParser extends LValParser { // Forward-declaration: defined in statement.js - +parseBlock: (allowDirectives?: boolean) => N.BlockStatement; + +parseBlock: ( + allowDirectives?: boolean, + createNewLexicalScope?: boolean, + ) => N.BlockStatement; +parseClass: ( node: N.Class, isStatement: boolean, @@ -41,10 +54,9 @@ export default class ExpressionParser extends LValParser { +parseDecorators: (allowExport?: boolean) => void; +parseFunction: ( node: T, - isStatement: boolean, + statement?: number, allowExpressionBody?: boolean, isAsync?: boolean, - optionalId?: boolean, ) => T; +parseFunctionParams: (node: N.Function, allowModifiers?: boolean) => void; +takeDecorators: (node: N.HasDecorators) => void; @@ -74,6 +86,7 @@ export default class ExpressionParser extends LValParser { // Convenience method to parse an Expression only getExpression(): N.Expression { + this.scope.enter(SCOPE_PROGRAM); this.nextToken(); const expr = this.parseExpression(); if (!this.match(tt.eof)) { @@ -128,7 +141,7 @@ export default class ExpressionParser extends LValParser { const startPos = this.state.start; const startLoc = this.state.startLoc; if (this.isContextual("yield")) { - if (this.state.inGenerator) { + if (this.scope.inGenerator) { let left = this.parseYield(noIn); if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); @@ -336,7 +349,7 @@ export default class ExpressionParser extends LValParser { if ( this.match(tt.name) && this.state.value === "await" && - this.state.inAsync + this.scope.inAsync ) { throw this.raise( this.state.start, @@ -421,8 +434,8 @@ export default class ExpressionParser extends LValParser { parseMaybeUnary(refShorthandDefaultPos: ?Pos): N.Expression { if ( this.isContextual("await") && - (this.state.inAsync || - (!this.state.inFunction && this.options.allowAwaitOutsideFunction)) + (this.scope.inAsync || + (!this.scope.inFunction && this.options.allowAwaitOutsideFunction)) ) { return this.parseAwait(); } else if (this.state.type.prefix) { @@ -806,11 +819,7 @@ export default class ExpressionParser extends LValParser { switch (this.state.type) { case tt._super: - if ( - !this.state.inMethod && - !this.state.inClassProperty && - !this.options.allowSuperOutsideMethod - ) { + if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) { this.raise( this.state.start, "super is only allowed in object methods and classes", @@ -819,6 +828,18 @@ export default class ExpressionParser extends LValParser { node = this.startNode(); this.next(); + if ( + this.match(tt.parenL) && + !this.scope.allowDirectSuper && + !this.options.allowSuperOutsideMethod + ) { + this.raise( + node.start, + "super() is only valid inside a class constructor of a subclass. " + + "Maybe a typo in the method name ('constructor') or not extending another class?", + ); + } + if ( !this.match(tt.parenL) && !this.match(tt.bracketL) && @@ -826,17 +847,7 @@ export default class ExpressionParser extends LValParser { ) { this.unexpected(); } - if ( - this.match(tt.parenL) && - this.state.inMethod !== "constructor" && - !this.options.allowSuperOutsideMethod - ) { - this.raise( - node.start, - "super() is only valid inside a class constructor. " + - "Make sure the method name is spelled exactly as 'constructor'.", - ); - } + return this.finishNode(node, "Super"); case tt._import: @@ -870,20 +881,17 @@ export default class ExpressionParser extends LValParser { !this.canInsertSemicolon() ) { this.next(); - return this.parseFunction(node, false, false, true); + return this.parseFunction(node, undefined, false, true); } else if ( canBeArrow && id.name === "async" && this.match(tt.name) && !this.canInsertSemicolon() ) { - const oldInAsync = this.state.inAsync; - this.state.inAsync = true; const params = [this.parseIdentifier()]; this.expect(tt.arrow); // let foo = async bar => {}; this.parseArrowExpression(node, params, true); - this.state.inAsync = oldInAsync; return node; } @@ -900,12 +908,9 @@ export default class ExpressionParser extends LValParser { this.expectPlugin("doExpressions"); const node = this.startNode(); this.next(); - const oldInFunction = this.state.inFunction; const oldLabels = this.state.labels; this.state.labels = []; - this.state.inFunction = false; - node.body = this.parseBlock(false); - this.state.inFunction = oldInFunction; + node.body = this.parseBlock(); this.state.labels = oldLabels; return this.finishNode(node, "DoExpression"); } @@ -1068,10 +1073,10 @@ export default class ExpressionParser extends LValParser { this.next(); meta = this.createIdentifier(meta, "function"); - if (this.state.inGenerator && this.eat(tt.dot)) { + if (this.scope.inGenerator && this.eat(tt.dot)) { return this.parseMetaProperty(node, meta, "sent"); } - return this.parseFunction(node, false); + return this.parseFunction(node); } parseMetaProperty( @@ -1309,7 +1314,7 @@ export default class ExpressionParser extends LValParser { if (this.eat(tt.dot)) { const metaProp = this.parseMetaProperty(node, meta, "target"); - if (!this.state.inFunction && !this.state.inClassProperty) { + if (!this.scope.inNonArrowFunction && !this.state.inClassProperty) { let error = "new.target can only be used in functions"; if (this.hasPlugin("classProperties")) { @@ -1575,6 +1580,7 @@ export default class ExpressionParser extends LValParser { isGenerator, isAsync, /* isConstructor */ false, + false, "ObjectMethod", ); } @@ -1588,6 +1594,7 @@ export default class ExpressionParser extends LValParser { /* isGenerator */ false, /* isAsync */ false, /* isConstructor */ false, + false, "ObjectMethod", ); this.checkGetterSetterParams(prop); @@ -1713,32 +1720,28 @@ export default class ExpressionParser extends LValParser { isGenerator: boolean, isAsync: boolean, isConstructor: boolean, + allowDirectSuper: boolean, type: string, + inClassScope: boolean = false, ): T { - const oldInFunc = this.state.inFunction; - const oldInMethod = this.state.inMethod; - const oldInAsync = this.state.inAsync; - const oldInGenerator = this.state.inGenerator; const oldYieldPos = this.state.yieldPos; const oldAwaitPos = this.state.awaitPos; - this.state.inFunction = true; - this.state.inMethod = node.kind || true; - this.state.inAsync = isAsync; - this.state.inGenerator = isGenerator; this.state.yieldPos = 0; this.state.awaitPos = 0; this.initFunction(node, isAsync); node.generator = !!isGenerator; const allowModifiers = isConstructor; // For TypeScript parameter properties + this.scope.enter( + functionFlags(isAsync, node.generator) | + SCOPE_SUPER | + (inClassScope ? SCOPE_CLASS : 0) | + (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0), + ); this.parseFunctionParams((node: any), allowModifiers); this.checkYieldAwaitInDefaultParams(); this.parseFunctionBodyAndFinish(node, type); - this.state.inFunction = oldInFunc; - this.state.inMethod = oldInMethod; - this.state.inAsync = oldInAsync; - this.state.inGenerator = oldInGenerator; this.state.yieldPos = oldYieldPos; this.state.awaitPos = oldAwaitPos; @@ -1753,17 +1756,12 @@ export default class ExpressionParser extends LValParser { params: ?(N.Expression[]), isAsync: boolean, ): N.ArrowFunctionExpression { + this.scope.enter(functionFlags(isAsync, false) | SCOPE_ARROW); this.initFunction(node, isAsync); - const oldInFunc = this.state.inFunction; - const oldInAsync = this.state.inAsync; - const oldInGenerator = this.state.inGenerator; const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; const oldYieldPos = this.state.yieldPos; const oldAwaitPos = this.state.awaitPos; - this.state.inFunction = true; - this.state.inAsync = isAsync; - this.state.inGenerator = false; this.state.maybeInArrowParameters = false; this.state.yieldPos = 0; this.state.awaitPos = 0; @@ -1771,9 +1769,6 @@ export default class ExpressionParser extends LValParser { if (params) this.setArrowFunctionParameters(node, params); this.parseFunctionBody(node, true); - this.state.inAsync = oldInAsync; - this.state.inGenerator = oldInGenerator; - this.state.inFunction = oldInFunc; this.state.maybeInArrowParameters = oldMaybeInArrowParameters; this.state.yieldPos = oldYieldPos; this.state.awaitPos = oldAwaitPos; @@ -1819,57 +1814,89 @@ export default class ExpressionParser extends LValParser { // Parse function body and check parameters. parseFunctionBody(node: N.Function, allowExpression: ?boolean): 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; if (isExpression) { node.body = this.parseMaybeAssign(); + this.checkParams(node, false, allowExpression); } 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, + "Illegal 'use strict' directive in function with non-simple parameter list", + ); + } + } // Start a new scope with regard to labels // flag (restore them to their old value afterwards). - const oldInFunc = this.state.inFunction; const oldLabels = this.state.labels; - this.state.inFunction = true; this.state.labels = []; - node.body = this.parseBlock(true); - this.state.inFunction = oldInFunc; + 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 && !nonSimple, + allowExpression, + ); + node.body = this.parseBlock(true, false); this.state.labels = oldLabels; } + this.scope.exit(); - this.checkFunctionNameAndParams(node, allowExpression); this.state.inParameters = oldInParameters; - } - - checkFunctionNameAndParams( - node: N.Function, - isArrowFunction: ?boolean, - ): void { - // 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`. - const isStrict = this.isStrictBody(node); - // Also check for arrow functions - const checkLVal = this.state.strict || isStrict || isArrowFunction; - - const oldStrict = this.state.strict; - if (isStrict) this.state.strict = isStrict; - - if (checkLVal) { - const nameHash: any = Object.create(null); - if (node.id) { - this.checkLVal(node.id, true, undefined, "function name"); - } - for (const param of node.params) { - if (isStrict && param.type !== "Identifier") { - this.raise(param.start, "Non-simple parameter in strict mode"); - } - this.checkLVal(param, true, nameHash, "function parameter list"); - } + // 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"); } this.state.strict = oldStrict; } + isSimpleParamList( + params: $ReadOnlyArray, + ): boolean { + for (let i = 0, len = params.length; i < len; i++) { + if (params[i].type !== "Identifier") return false; + } + return true; + } + + checkParams( + node: N.Function, + allowDuplicates: boolean, + // eslint-disable-next-line no-unused-vars + isArrowFunction: ?boolean, + ): void { + // $FlowIssue + const nameHash: {} = Object.create(null); + for (let i = 0; i < node.params.length; i++) { + this.checkLVal( + node.params[i], + BIND_VAR, + allowDuplicates ? null : nameHash, + "function paramter list", + ); + } + } + // Parses a comma-separated list of expressions, and returns them as // an array. `close` is the token type that ends the list, and // `allowEmpty` can be turned on to allow subsequent commas with @@ -1987,22 +2014,21 @@ export default class ExpressionParser extends LValParser { checkKeywords: boolean, isBinding: boolean, ): void { - const state = this.state; - if (state.inGenerator && word === "yield") { + if (this.scope.inGenerator && word === "yield") { this.raise( startLoc, "Can not use 'yield' as identifier inside a generator", ); } - if (state.inAsync && word === "await") { + if (this.scope.inAsync && word === "await") { this.raise( startLoc, "Can not use 'await' as identifier inside an async function", ); } - if (state.inClassProperty && word === "arguments") { + if (this.state.inClassProperty && word === "arguments") { this.raise( startLoc, "'arguments' is not allowed in class field initializer", @@ -2012,14 +2038,14 @@ export default class ExpressionParser extends LValParser { this.raise(startLoc, `Unexpected keyword '${word}'`); } - const reservedTest = !state.strict + const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord; if (reservedTest(word, this.inModule)) { - if (!state.inAsync && word === "await") { + if (!this.scope.inAsync && word === "await") { this.raise( startLoc, "Can not use keyword 'await' outside an async function", diff --git a/packages/babel-parser/src/parser/index.js b/packages/babel-parser/src/parser/index.js index 00617bd863..b92ecb8203 100644 --- a/packages/babel-parser/src/parser/index.js +++ b/packages/babel-parser/src/parser/index.js @@ -5,6 +5,8 @@ import type { File, JSXOpeningElement } from "../types"; import type { PluginList } from "../plugin-utils"; import { getOptions } from "../options"; import StatementParser from "./statement"; +import { SCOPE_PROGRAM } from "../util/scopeflags"; +import ScopeHandler from "../util/scope"; export type PluginsMap = Map; @@ -20,11 +22,13 @@ export default class Parser extends StatementParser { this.options = options; this.inModule = this.options.sourceType === "module"; + this.scope = new ScopeHandler(this.raise.bind(this), this.inModule); this.plugins = pluginsMap(this.options.plugins); this.filename = options.sourceFilename; } parse(): File { + this.scope.enter(SCOPE_PROGRAM); const file = this.startNode(); const program = this.startNode(); this.nextToken(); diff --git a/packages/babel-parser/src/parser/lval.js b/packages/babel-parser/src/parser/lval.js index 6b9e6c6ac9..1711b7ae7d 100644 --- a/packages/babel-parser/src/parser/lval.js +++ b/packages/babel-parser/src/parser/lval.js @@ -16,6 +16,7 @@ import type { import type { Pos, Position } from "../util/location"; import { isStrictBindReservedWord } from "../util/identifier"; import { NodeUtils } from "./node"; +import { type BindingTypes, BIND_NONE, BIND_OUTSIDE } from "../util/scopeflags"; export default class LValParser extends NodeUtils { // Forward-declaration: defined in expression.js @@ -262,7 +263,7 @@ export default class LValParser extends NodeUtils { elts.push(this.parseAssignableListItemTypes(this.parseRest())); this.checkCommaAfterRest( close, - this.state.inFunction && this.state.inParameters + this.scope.inFunction && this.state.inParameters ? "parameter" : "element", ); @@ -325,7 +326,7 @@ export default class LValParser extends NodeUtils { checkLVal( expr: Expression, - isBinding: ?boolean, + bindingType: ?BindingTypes = BIND_NONE, checkClashes: ?{ [key: string]: boolean }, contextDescription: string, ): void { @@ -337,7 +338,7 @@ export default class LValParser extends NodeUtils { ) { this.raise( expr.start, - `${isBinding ? "Binding" : "Assigning to"} '${ + `${bindingType === BIND_NONE ? "Assigning to" : "Binding"} '${ expr.name }' in strict mode`, ); @@ -358,15 +359,20 @@ export default class LValParser extends NodeUtils { const key = `_${expr.name}`; if (checkClashes[key]) { - this.raise(expr.start, "Argument name clash in strict mode"); + this.raise(expr.start, "Argument name clash"); } else { checkClashes[key] = true; } } + if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) { + this.scope.declareName(expr.name, bindingType, expr.start); + } break; case "MemberExpression": - if (isBinding) this.raise(expr.start, "Binding member expression"); + if (bindingType !== BIND_NONE) { + this.raise(expr.start, "Binding member expression"); + } break; case "ObjectPattern": @@ -374,7 +380,7 @@ export default class LValParser extends NodeUtils { if (prop.type === "ObjectProperty") prop = prop.value; this.checkLVal( prop, - isBinding, + bindingType, checkClashes, "object destructuring pattern", ); @@ -386,7 +392,7 @@ export default class LValParser extends NodeUtils { if (elem) { this.checkLVal( elem, - isBinding, + bindingType, checkClashes, "array destructuring pattern", ); @@ -397,21 +403,26 @@ export default class LValParser extends NodeUtils { case "AssignmentPattern": this.checkLVal( expr.left, - isBinding, + bindingType, checkClashes, "assignment pattern", ); break; case "RestElement": - this.checkLVal(expr.argument, isBinding, checkClashes, "rest element"); + this.checkLVal( + expr.argument, + bindingType, + checkClashes, + "rest element", + ); break; default: { const message = - (isBinding - ? /* istanbul ignore next */ "Binding invalid" - : "Invalid") + + (bindingType === BIND_NONE + ? "Invalid" + : /* istanbul ignore next */ "Binding invalid") + " left-hand side" + (contextDescription ? " in " + contextDescription diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 88d6555d5f..5e77de8ba3 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -10,6 +10,17 @@ import { } from "../util/identifier"; import { lineBreak, skipWhiteSpace } from "../util/whitespace"; import * as charCodes from "charcodes"; +import { + BIND_SIMPLE_CATCH, + BIND_LEXICAL, + BIND_VAR, + BIND_FUNCTION, + functionFlags, + SCOPE_CLASS, + SCOPE_OTHER, + SCOPE_SIMPLE_CATCH, + SCOPE_SUPER, +} from "../util/scopeflags"; // Reused empty array added for node fields that are always empty. @@ -18,6 +29,11 @@ const empty = []; const loopLabel = { kind: "loop" }, switchLabel = { kind: "switch" }; +const FUNC_NO_FLAGS = 0b000, + FUNC_STATEMENT = 0b001, + FUNC_HANGING_STATEMENT = 0b010, + FUNC_NULLABLE_ID = 0b100; + export default class StatementParser extends ExpressionParser { // ### Statement parsing @@ -144,26 +160,24 @@ export default class StatementParser extends ExpressionParser { return this.parseDoStatement(node); case tt._for: return this.parseForStatement(node); - case tt._function: { + case tt._function: if (this.lookahead().type === tt.dot) break; - if ( - context && - (this.state.strict || (context !== "if" && context !== "label")) - ) { - this.raise( - this.state.start, - "Function declaration not allowed in this context", - ); + if (context) { + if (this.state.strict) { + this.raise( + this.state.start, + "In strict mode code, functions can only be declared at top level or inside a block", + ); + } else if (context !== "if" && context !== "label") { + this.raise( + this.state.start, + "In non-strict mode code, functions can only be declared at top level, " + + "inside a block, or as the body of an if statement", + ); + } } - const result = this.parseFunctionStatement(node); + return this.parseFunctionStatement(node, false, !context); - // TODO: Remove this once we have proper scope tracking in place. - if (context && result.generator) { - this.unexpected(node.start); - } - - return result; - } case tt._class: if (context) this.unexpected(); return this.parseClass(node, true); @@ -182,7 +196,12 @@ export default class StatementParser extends ExpressionParser { case tt._const: case tt._var: kind = kind || this.state.value; - if (context && kind !== "var") this.unexpected(); + if (context && kind !== "var") { + this.unexpected( + this.state.start, + "Lexical declaration cannot appear in a single-statement context", + ); + } return this.parseVarStatement(node, kind); case tt._while: @@ -237,24 +256,19 @@ export default class StatementParser extends ExpressionParser { return result; } - case tt.name: - if (this.isContextual("async")) { - // peek ahead and see if next token is a function - const state = this.state.clone(); - this.next(); - if (this.match(tt._function) && !this.canInsertSemicolon()) { - if (context) { - this.raise( - this.state.lastTokStart, - "Function declaration not allowed in this context", - ); - } - this.next(); - return this.parseFunction(node, true, false, true); - } else { - this.state = state; + + default: { + if (this.isAsyncFunction()) { + if (context) { + this.unexpected( + null, + "Async functions can only be declared at the top level or inside a block", + ); } + this.next(); + return this.parseFunctionStatement(node, true, !context); } + } } // If the statement does not start with a statement keyword or a @@ -461,12 +475,13 @@ export default class StatementParser extends ExpressionParser { let awaitAt = -1; if ( - (this.state.inAsync || - (!this.state.inFunction && this.options.allowAwaitOutsideFunction)) && + (this.scope.inAsync || + (!this.scope.inFunction && this.options.allowAwaitOutsideFunction)) && this.eatContextual("await") ) { awaitAt = this.state.lastTokStart; } + this.scope.enter(SCOPE_OTHER); this.expect(tt.parenL); if (this.match(tt.semi)) { @@ -524,9 +539,18 @@ export default class StatementParser extends ExpressionParser { return this.parseFor(node, init); } - parseFunctionStatement(node: N.FunctionDeclaration): N.FunctionDeclaration { + parseFunctionStatement( + node: N.FunctionDeclaration, + isAsync?: boolean, + declarationPosition?: boolean, + ): N.FunctionDeclaration { this.next(); - return this.parseFunction(node, true); + return this.parseFunction( + node, + FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), + false, + isAsync, + ); } parseIfStatement(node: N.IfStatement): N.IfStatement { @@ -538,7 +562,7 @@ export default class StatementParser extends ExpressionParser { } parseReturnStatement(node: N.ReturnStatement): N.ReturnStatement { - if (!this.state.inFunction && !this.options.allowReturnOutsideFunction) { + if (!this.scope.inFunction && !this.options.allowReturnOutsideFunction) { this.raise(this.state.start, "'return' outside of function"); } @@ -564,6 +588,7 @@ export default class StatementParser extends ExpressionParser { const cases = (node.cases = []); this.expect(tt.braceL); this.state.labels.push(switchLabel); + this.scope.enter(SCOPE_OTHER); // Statements under must be grouped (by label) in SwitchCase // nodes. `cur` is used to keep the node that we are currently @@ -595,6 +620,7 @@ export default class StatementParser extends ExpressionParser { } } } + this.scope.exit(); if (cur) this.finishNode(cur, "SwitchCase"); this.next(); // Closing brace this.state.labels.pop(); @@ -627,11 +653,18 @@ export default class StatementParser extends ExpressionParser { if (this.match(tt.parenL)) { this.expect(tt.parenL); clause.param = this.parseBindingAtom(); - const clashes: any = Object.create(null); - this.checkLVal(clause.param, true, clashes, "catch clause"); + const simple = clause.param.type === "Identifier"; + this.scope.enter(simple ? SCOPE_SIMPLE_CATCH : 0); + this.checkLVal( + clause.param, + simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL, + null, + "catch clause", + ); this.expect(tt.parenR); } else { clause.param = null; + this.scope.enter(SCOPE_OTHER); } clause.body = @@ -641,8 +674,9 @@ export default class StatementParser extends ExpressionParser { // outside of the function body. this.withTopicForbiddingContext(() => // Parse the catch clause's body. - this.parseBlock(false), + this.parseBlock(false, false), ); + this.scope.exit(); node.handler = this.finishNode(clause, "CatchClause"); } @@ -769,10 +803,19 @@ export default class StatementParser extends ExpressionParser { // strict"` declarations when `allowStrict` is true (used for // function bodies). - parseBlock(allowDirectives?: boolean): N.BlockStatement { + parseBlock( + allowDirectives?: boolean = false, + createNewLexicalScope?: boolean = true, + ): N.BlockStatement { const node = this.startNode(); this.expect(tt.braceL); + if (createNewLexicalScope) { + this.scope.enter(SCOPE_OTHER); + } this.parseBlockBody(node, allowDirectives, false, tt.braceR); + if (createNewLexicalScope) { + this.scope.exit(); + } return this.finishNode(node, "BlockStatement"); } @@ -858,6 +901,7 @@ export default class StatementParser extends ExpressionParser { node.update = this.match(tt.parenR) ? null : this.parseExpression(); this.expect(tt.parenR); + this.scope.exit(); node.body = // For the smartPipelines plugin: Disable topic references from outer // contexts within the loop body. They are permitted in test expressions, @@ -893,6 +937,7 @@ export default class StatementParser extends ExpressionParser { node.right = this.parseExpression(); this.expect(tt.parenR); + this.scope.exit(); node.body = // For the smartPipelines plugin: // Disable topic references from outer contexts within the loop body. @@ -954,7 +999,12 @@ export default class StatementParser extends ExpressionParser { this.unexpected(null, "let is disallowed as a lexically bound name"); } decl.id = this.parseBindingAtom(); - this.checkLVal(decl.id, true, undefined, "variable declaration"); + this.checkLVal( + decl.id, + kind === "var" ? BIND_VAR : BIND_LEXICAL, + undefined, + "variable declaration", + ); } // Parse a function declaration or literal (depending on the @@ -962,51 +1012,56 @@ export default class StatementParser extends ExpressionParser { parseFunction( node: T, - isStatement: boolean, + statement?: number = FUNC_NO_FLAGS, allowExpressionBody?: boolean = false, isAsync?: boolean = false, - optionalId?: boolean = false, ): T { - const oldInFunc = this.state.inFunction; - const oldInMethod = this.state.inMethod; - const oldInAsync = this.state.inAsync; - const oldInGenerator = this.state.inGenerator; - const oldInClassProperty = this.state.inClassProperty; - const oldYieldPos = this.state.yieldPos; - const oldAwaitPos = this.state.awaitPos; - this.state.inFunction = true; - this.state.inMethod = false; - this.state.inClassProperty = false; - this.state.yieldPos = 0; - this.state.awaitPos = 0; + const isStatement = statement & FUNC_STATEMENT; + const isHangingStatement = statement & FUNC_HANGING_STATEMENT; this.initFunction(node, isAsync); + if (this.match(tt.star) && isHangingStatement) { + this.unexpected( + this.state.start, + "Generators can only be declared at the top level or inside a block", + ); + } node.generator = this.eat(tt.star); - if (isStatement && !optionalId && !this.match(tt.name)) { - this.unexpected(); + if (isStatement) { + node.id = + statement & FUNC_NULLABLE_ID && !this.match(tt.name) + ? null + : this.parseIdentifier(); + if (node.id && !isHangingStatement) { + // If it is a regular function declaration in sloppy mode, then it is + // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding + // mode depends on properties of the current scope (see + // treatFunctionsAsVar). + this.checkLVal( + node.id, + this.state.strict || node.generator || node.async + ? this.scope.treatFunctionsAsVar + ? BIND_VAR + : BIND_LEXICAL + : BIND_FUNCTION, + null, + "function name", + ); + } } - // When parsing function expression, the binding identifier is parsed - // according to the rules inside the function. - // e.g. (function* yield() {}) is invalid because "yield" is disallowed in - // generators. - // This isn't the case with function declarations: function* yield() {} is - // valid because yield is parsed as if it was outside the generator. - // Therefore, this.state.inGenerator is set before or after parsing the - // function id according to the "isStatement" parameter. - // The same applies to await & async functions. + const oldInClassProperty = this.state.inClassProperty; + const oldYieldPos = this.state.yieldPos; + const oldAwaitPos = this.state.awaitPos; + this.state.inClassProperty = false; + this.state.yieldPos = 0; + this.state.awaitPos = 0; + this.scope.enter(functionFlags(node.async, node.generator)); + if (!isStatement) { - this.state.inAsync = isAsync; - this.state.inGenerator = node.generator; - } - if (this.match(tt.name)) { - node.id = this.parseIdentifier(); - } - if (isStatement) { - this.state.inAsync = isAsync; - this.state.inGenerator = node.generator; + node.id = this.match(tt.name) ? this.parseIdentifier() : null; } this.parseFunctionParams(node); @@ -1023,10 +1078,6 @@ export default class StatementParser extends ExpressionParser { ); }); - this.state.inFunction = oldInFunc; - this.state.inMethod = oldInMethod; - this.state.inAsync = oldInAsync; - this.state.inGenerator = oldInGenerator; this.state.inClassProperty = oldInClassProperty; this.state.yieldPos = oldYieldPos; this.state.awaitPos = oldAwaitPos; @@ -1099,11 +1150,12 @@ export default class StatementParser extends ExpressionParser { const state = { hadConstructor: false }; let decorators: N.Decorator[] = []; const classBody: N.ClassBody = this.startNode(); - classBody.body = []; this.expect(tt.braceL); + const constructorAllowsSuper = node.superClass !== null; + // For the smartPipelines plugin: Disable topic references from outer // contexts within the class body. They are permitted in test expressions, // outside of the class body. @@ -1133,7 +1185,7 @@ export default class StatementParser extends ExpressionParser { decorators = []; } - this.parseClassMember(classBody, member, state); + this.parseClassMember(classBody, member, state, constructorAllowsSuper); if ( member.kind === "constructor" && @@ -1164,6 +1216,7 @@ export default class StatementParser extends ExpressionParser { classBody: N.ClassBody, member: N.ClassMember, state: { hadConstructor: boolean }, + constructorAllowsSuper: boolean, ): void { let isStatic = false; const containsEsc = this.state.containsEsc; @@ -1185,6 +1238,7 @@ export default class StatementParser extends ExpressionParser { false, false, /* isConstructor */ false, + false, ); return; } else if (this.isClassProperty()) { @@ -1204,7 +1258,13 @@ export default class StatementParser extends ExpressionParser { isStatic = true; } - this.parseClassMemberWithIsStatic(classBody, member, state, isStatic); + this.parseClassMemberWithIsStatic( + classBody, + member, + state, + isStatic, + constructorAllowsSuper, + ); } parseClassMemberWithIsStatic( @@ -1212,6 +1272,7 @@ export default class StatementParser extends ExpressionParser { member: N.ClassMember, state: { hadConstructor: boolean }, isStatic: boolean, + constructorAllowsSuper: boolean, ) { const publicMethod: $FlowSubtype = member; const privateMethod: $FlowSubtype = member; @@ -1244,6 +1305,7 @@ export default class StatementParser extends ExpressionParser { true, false, /* isConstructor */ false, + false, ); return; @@ -1266,7 +1328,7 @@ export default class StatementParser extends ExpressionParser { // a normal method const isConstructor = this.isNonstaticConstructor(publicMethod); - + let allowsDirectSuper = false; if (isConstructor) { publicMethod.kind = "constructor"; @@ -1282,6 +1344,7 @@ export default class StatementParser extends ExpressionParser { this.raise(key.start, "Duplicate constructor in the same class"); } state.hadConstructor = true; + allowsDirectSuper = constructorAllowsSuper; } this.pushClassMethod( @@ -1290,6 +1353,7 @@ export default class StatementParser extends ExpressionParser { false, false, isConstructor, + allowsDirectSuper, ); } else if (this.isClassProperty()) { if (isPrivate) { @@ -1327,6 +1391,7 @@ export default class StatementParser extends ExpressionParser { isGenerator, true, /* isConstructor */ false, + false, ); } } else if ( @@ -1356,6 +1421,7 @@ export default class StatementParser extends ExpressionParser { false, false, /* isConstructor */ false, + false, ); } @@ -1422,6 +1488,7 @@ export default class StatementParser extends ExpressionParser { isGenerator: boolean, isAsync: boolean, isConstructor: boolean, + allowsDirectSuper: boolean, ): void { classBody.body.push( this.parseMethod( @@ -1429,7 +1496,9 @@ export default class StatementParser extends ExpressionParser { isGenerator, isAsync, isConstructor, + allowsDirectSuper, "ClassMethod", + true, ), ); } @@ -1447,7 +1516,9 @@ export default class StatementParser extends ExpressionParser { isGenerator, isAsync, /* isConstructor */ false, + false, "ClassPrivateMethod", + true, ), ); } @@ -1466,13 +1537,16 @@ export default class StatementParser extends ExpressionParser { parseClassPrivateProperty( node: N.ClassPrivateProperty, ): N.ClassPrivateProperty { - const oldInMethod = this.state.inMethod; - this.state.inMethod = false; this.state.inClassProperty = true; + + this.scope.enter(SCOPE_CLASS | SCOPE_SUPER); + node.value = this.eat(tt.eq) ? this.parseMaybeAssign() : null; this.semicolon(); this.state.inClassProperty = false; - this.state.inMethod = oldInMethod; + + this.scope.exit(); + return this.finishNode(node, "ClassPrivateProperty"); } @@ -1481,10 +1555,10 @@ export default class StatementParser extends ExpressionParser { this.expectPlugin("classProperties"); } - const oldInMethod = this.state.inMethod; - this.state.inMethod = false; this.state.inClassProperty = true; + this.scope.enter(SCOPE_CLASS | SCOPE_SUPER); + if (this.match(tt.eq)) { this.expectPlugin("classProperties"); this.next(); @@ -1494,7 +1568,8 @@ export default class StatementParser extends ExpressionParser { } this.semicolon(); this.state.inClassProperty = false; - this.state.inMethod = oldInMethod; + + this.scope.exit(); return this.finishNode(node, "ClassProperty"); } @@ -1506,6 +1581,9 @@ export default class StatementParser extends ExpressionParser { ): void { if (this.match(tt.name)) { node.id = this.parseIdentifier(); + if (isStatement) { + this.checkLVal(node.id, BIND_LEXICAL, undefined, "class name"); + } } else { if (optionalId || !isStatement) { node.id = null; @@ -1642,7 +1720,7 @@ export default class StatementParser extends ExpressionParser { return false; } - isAsyncFunction() { + isAsyncFunction(): boolean { if (!this.isContextual("async")) return false; const { input, pos, length } = this.state; @@ -1666,13 +1744,18 @@ export default class StatementParser extends ExpressionParser { const isAsync = this.isAsyncFunction(); - if (this.eat(tt._function) || isAsync) { + if (this.match(tt._function) || isAsync) { + this.next(); if (isAsync) { - this.eatContextual("async"); - this.expect(tt._function); + this.next(); } - return this.parseFunction(expr, true, false, isAsync, true); + return this.parseFunction( + expr, + FUNC_STATEMENT | FUNC_NULLABLE_ID, + false, + isAsync, + ); } else if (this.match(tt._class)) { return this.parseClass(expr, true, true); } else if (this.match(tt.at)) { @@ -1927,7 +2010,12 @@ export default class StatementParser extends ExpressionParser { contextDescription: string, ): void { specifier.local = this.parseIdentifier(); - this.checkLVal(specifier.local, true, undefined, contextDescription); + this.checkLVal( + specifier.local, + BIND_LEXICAL, + undefined, + contextDescription, + ); node.specifiers.push(this.finishNode(specifier, type)); } @@ -2000,7 +2088,12 @@ export default class StatementParser extends ExpressionParser { ); specifier.local = specifier.imported.__clone(); } - this.checkLVal(specifier.local, true, undefined, "import specifier"); + this.checkLVal( + specifier.local, + BIND_LEXICAL, + undefined, + "import specifier", + ); node.specifiers.push(this.finishNode(specifier, "ImportSpecifier")); } } diff --git a/packages/babel-parser/src/parser/util.js b/packages/babel-parser/src/parser/util.js index 1ea8aeaf8f..4c8eb453a8 100644 --- a/packages/babel-parser/src/parser/util.js +++ b/packages/babel-parser/src/parser/util.js @@ -3,7 +3,9 @@ import { types as tt, type TokenType } from "../tokenizer/types"; import Tokenizer from "../tokenizer"; import type { Node } from "../types"; -import { lineBreak } from "../util/whitespace"; +import { lineBreak, skipWhiteSpace } from "../util/whitespace"; + +const literal = /^(?:;|('|")((?:\\?.)*?)\1)/; // ## Parser utilities @@ -165,4 +167,18 @@ export default class UtilParser extends Tokenizer { ); } } + + strictDirective(start: number): boolean { + for (;;) { + skipWhiteSpace.lastIndex = start; + // $FlowIgnore + start += skipWhiteSpace.exec(this.state.input)[0].length; + const match = literal.exec(this.state.input.slice(start)); + if (!match) break; + if (match[2] === "use strict") return true; + start += match[0].length; + } + + return false; + } } diff --git a/packages/babel-parser/src/plugins/estree.js b/packages/babel-parser/src/plugins/estree.js index ae859107b0..0a5a276a2b 100644 --- a/packages/babel-parser/src/plugins/estree.js +++ b/packages/babel-parser/src/plugins/estree.js @@ -4,6 +4,7 @@ import { types as tt, TokenType } from "../tokenizer/types"; import type Parser from "../parser"; import * as N from "../types"; import type { Pos, Position } from "../util/location"; +import { type BindingTypes, BIND_NONE } from "../util/scopeflags"; function isSimpleProperty(node: N.Node): boolean { return ( @@ -104,7 +105,7 @@ export default (superClass: Class): Class => checkLVal( expr: N.Expression, - isBinding: ?boolean, + bindingType: ?BindingTypes = BIND_NONE, checkClashes: ?{ [key: string]: boolean }, contextDescription: string, ): void { @@ -113,14 +114,14 @@ export default (superClass: Class): Class => expr.properties.forEach(prop => { this.checkLVal( prop.type === "Property" ? prop.value : prop, - isBinding, + bindingType, checkClashes, "object destructuring pattern", ); }); break; default: - super.checkLVal(expr, isBinding, checkClashes, contextDescription); + super.checkLVal(expr, bindingType, checkClashes, contextDescription); } } @@ -203,13 +204,16 @@ export default (superClass: Class): Class => isGenerator: boolean, isAsync: boolean, isConstructor: boolean, + allowsDirectSuper: boolean, ): void { this.parseMethod( method, isGenerator, isAsync, isConstructor, + allowsDirectSuper, "MethodDefinition", + true, ); if (method.typeParameters) { // $FlowIgnore @@ -265,7 +269,9 @@ export default (superClass: Class): Class => isGenerator: boolean, isAsync: boolean, isConstructor: boolean, + allowDirectSuper: boolean, type: string, + inClassScope: boolean = false, ): T { let funcNode = this.startNode(); funcNode.kind = node.kind; // provide kind, so super method correctly sets state @@ -274,7 +280,9 @@ export default (superClass: Class): Class => isGenerator, isAsync, isConstructor, + allowDirectSuper, "FunctionExpression", + inClassScope, ); delete funcNode.kind; // $FlowIgnore diff --git a/packages/babel-parser/src/plugins/flow.js b/packages/babel-parser/src/plugins/flow.js index 1effe1725c..af151c317d 100644 --- a/packages/babel-parser/src/plugins/flow.js +++ b/packages/babel-parser/src/plugins/flow.js @@ -9,6 +9,12 @@ import type State from "../tokenizer/state"; import { types as tc } from "../tokenizer/context"; import * as charCodes from "charcodes"; import { isIteratorStart } from "../util/identifier"; +import { + type BindingTypes, + BIND_NONE, + BIND_LEXICAL, + SCOPE_OTHER, +} from "../util/scopeflags"; const reservedTypes = [ "any", @@ -257,6 +263,8 @@ export default (superClass: Class): Class => flowParseDeclareModule(node: N.FlowDeclareModule): N.FlowDeclareModule { this.next(); + this.scope.enter(SCOPE_OTHER); + if (this.match(tt.string)) { node.id = this.parseExprAtom(); } else { @@ -290,6 +298,9 @@ export default (superClass: Class): Class => body.push(bodyNode); } + + this.scope.exit(); + this.expect(tt.braceR); this.finishNode(bodyNode, "BlockStatement"); @@ -518,6 +529,7 @@ export default (superClass: Class): Class => flowParseTypeAlias(node: N.FlowTypeAlias): N.FlowTypeAlias { node.id = this.flowParseRestrictedIdentifier(); + this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start); if (this.isRelational("<")) { node.typeParameters = this.flowParseTypeParameterDeclaration(); @@ -537,6 +549,7 @@ export default (superClass: Class): Class => ): N.FlowOpaqueType { this.expectContextual("type"); node.id = this.flowParseRestrictedIdentifier(/*liberal*/ true); + this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start); if (this.isRelational("<")) { node.typeParameters = this.flowParseTypeParameterDeclaration(); @@ -1761,7 +1774,7 @@ export default (superClass: Class): Class => "arrow function parameters", ); // Use super's method to force the parameters to be checked - super.checkFunctionNameAndParams(node, true); + super.checkParams(node, false, true); } else { arrows.push(node); } @@ -1995,14 +2008,14 @@ export default (superClass: Class): Class => checkLVal( expr: N.Expression, - isBinding: ?boolean, + bindingType: ?BindingTypes = BIND_NONE, checkClashes: ?{ [key: string]: boolean }, contextDescription: string, ): void { if (expr.type !== "TypeCastExpression") { return super.checkLVal( expr, - isBinding, + bindingType, checkClashes, contextDescription, ); @@ -2047,6 +2060,7 @@ export default (superClass: Class): Class => isGenerator: boolean, isAsync: boolean, isConstructor: boolean, + allowsDirectSuper: boolean, ): void { if ((method: $FlowFixMe).variance) { this.unexpected((method: $FlowFixMe).variance.start); @@ -2064,6 +2078,7 @@ export default (superClass: Class): Class => isGenerator, isAsync, isConstructor, + allowsDirectSuper, ); } @@ -2217,7 +2232,12 @@ export default (superClass: Class): Class => ? this.flowParseRestrictedIdentifier(true) : this.parseIdentifier(); - this.checkLVal(specifier.local, true, undefined, contextDescription); + this.checkLVal( + specifier.local, + BIND_LEXICAL, + undefined, + contextDescription, + ); node.specifiers.push(this.finishNode(specifier, type)); } @@ -2327,12 +2347,17 @@ export default (superClass: Class): Class => ); } - this.checkLVal(specifier.local, true, undefined, "import specifier"); + this.checkLVal( + specifier.local, + BIND_LEXICAL, + undefined, + "import specifier", + ); node.specifiers.push(this.finishNode(specifier, "ImportSpecifier")); } // parse function type parameters - function foo() {} - parseFunctionParams(node: N.Function): void { + parseFunctionParams(node: N.Function, allowModifiers?: boolean): void { // $FlowFixMe const kind = node.kind; if (kind !== "get" && kind !== "set" && this.isRelational("<")) { @@ -2340,7 +2365,7 @@ export default (superClass: Class): Class => /* allowDefault */ false, ); } - super.parseFunctionParams(node); + super.parseFunctionParams(node, allowModifiers); } // parse flow type annotations on variable declarator heads - let foo: string = bar @@ -2519,8 +2544,9 @@ export default (superClass: Class): Class => } } - checkFunctionNameAndParams( + checkParams( node: N.Function, + allowDuplicates: boolean, isArrowFunction: ?boolean, ): void { if ( @@ -2530,7 +2556,7 @@ export default (superClass: Class): Class => return; } - return super.checkFunctionNameAndParams(node, isArrowFunction); + return super.checkParams(node, allowDuplicates, isArrowFunction); } parseParenAndDistinguishExpression(canBeArrow: boolean): N.Expression { diff --git a/packages/babel-parser/src/plugins/typescript.js b/packages/babel-parser/src/plugins/typescript.js index 1c0961ab97..7418fd7221 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -6,6 +6,13 @@ import { types as ct } from "../tokenizer/context"; import * as N from "../types"; import type { Pos, Position } from "../util/location"; import Parser from "../parser"; +import { + type BindingTypes, + functionFlags, + BIND_NONE, + SCOPE_ARROW, + SCOPE_OTHER, +} from "../util/scopeflags"; type TsModifier = | "readonly" @@ -1071,6 +1078,8 @@ export default (superClass: Class): Class => tsParseModuleBlock(): N.TsModuleBlock { const node: N.TsModuleBlock = this.startNode(); + this.scope.enter(SCOPE_OTHER); + this.expect(tt.braceL); // Inside of a module block is considered "top-level", meaning it can have imports and exports. this.parseBlockOrModuleBlockBody( @@ -1079,6 +1088,7 @@ export default (superClass: Class): Class => /* topLevel */ true, /* end */ tt.braceR, ); + this.scope.exit(); return this.finishNode(node, "TSModuleBlock"); } @@ -1217,8 +1227,7 @@ export default (superClass: Class): Class => switch (starttype) { case tt._function: - this.next(); - return this.parseFunction(nany, /* isStatement */ true); + return this.parseFunctionStatement(nany); case tt._class: return this.parseClass( nany, @@ -1372,17 +1381,13 @@ export default (superClass: Class): Class => return undefined; } - const oldInAsync = this.state.inAsync; - const oldInGenerator = this.state.inGenerator; - this.state.inAsync = true; - this.state.inGenerator = false; + this.scope.enter(functionFlags(true, false) | SCOPE_ARROW); + res.id = null; res.generator = false; res.expression = true; // May be set again by parseFunctionBody. res.async = true; this.parseFunctionBody(res, true); - this.state.inAsync = oldInAsync; - this.state.inGenerator = oldInGenerator; return this.finishNode(res, "ArrowFunctionExpression"); } @@ -1721,11 +1726,12 @@ export default (superClass: Class): Class => classBody: N.ClassBody, member: any, state: { hadConstructor: boolean }, + constructorAllowsSuper: boolean, ): void { const accessibility = this.parseAccessModifier(); if (accessibility) member.accessibility = accessibility; - super.parseClassMember(classBody, member, state); + super.parseClassMember(classBody, member, state, constructorAllowsSuper); } parseClassMemberWithIsStatic( @@ -1733,6 +1739,7 @@ export default (superClass: Class): Class => member: any, state: { hadConstructor: boolean }, isStatic: boolean, + constructorAllowsSuper: boolean, ): void { const methodOrProp: N.ClassMethod | N.ClassProperty = member; const prop: N.ClassProperty = member; @@ -1773,7 +1780,13 @@ export default (superClass: Class): Class => return; } - super.parseClassMemberWithIsStatic(classBody, member, state, isStatic); + super.parseClassMemberWithIsStatic( + classBody, + member, + state, + isStatic, + constructorAllowsSuper, + ); } parsePostMemberNameModifiers( @@ -1923,6 +1936,7 @@ export default (superClass: Class): Class => isGenerator: boolean, isAsync: boolean, isConstructor: boolean, + allowsDirectSuper: boolean, ): void { const typeParameters = this.tsTryParseTypeParameters(); if (typeParameters) method.typeParameters = typeParameters; @@ -1932,6 +1946,7 @@ export default (superClass: Class): Class => isGenerator, isAsync, isConstructor, + allowsDirectSuper, ); } @@ -2154,7 +2169,7 @@ export default (superClass: Class): Class => checkLVal( expr: N.Expression, - isBinding: ?boolean, + bindingType: ?BindingTypes = BIND_NONE, checkClashes: ?{ [key: string]: boolean }, contextDescription: string, ): void { @@ -2167,7 +2182,7 @@ export default (superClass: Class): Class => case "TSParameterProperty": this.checkLVal( expr.parameter, - isBinding, + bindingType, checkClashes, "parameter property", ); @@ -2177,13 +2192,13 @@ export default (superClass: Class): Class => case "TSTypeAssertion": this.checkLVal( expr.expression, - isBinding, + bindingType, checkClashes, contextDescription, ); return; default: - super.checkLVal(expr, isBinding, checkClashes, contextDescription); + super.checkLVal(expr, bindingType, checkClashes, contextDescription); return; } } diff --git a/packages/babel-parser/src/tokenizer/context.js b/packages/babel-parser/src/tokenizer/context.js index 6add1a4cf7..f89897b27a 100644 --- a/packages/babel-parser/src/tokenizer/context.js +++ b/packages/babel-parser/src/tokenizer/context.js @@ -60,7 +60,7 @@ tt.name.updateContext = function(prevType) { if (prevType !== tt.dot) { if ( (this.state.value === "of" && !this.state.exprAllowed) || - (this.state.value === "yield" && this.state.inGenerator) + (this.state.value === "yield" && this.scope.inGenerator) ) { allowed = true; } diff --git a/packages/babel-parser/src/tokenizer/state.js b/packages/babel-parser/src/tokenizer/state.js index 0215532dd0..c8ef367425 100644 --- a/packages/babel-parser/src/tokenizer/state.js +++ b/packages/babel-parser/src/tokenizer/state.js @@ -66,13 +66,9 @@ export default class State { // and then convert them, we need to track it. commaAfterSpreadAt: number = -1; - // Flags to track whether we are in a function, a generator. - inFunction: boolean = false; + // Flags to track inParameters: boolean = false; maybeInArrowParameters: boolean = false; - inGenerator: boolean = false; - inMethod: boolean | N.MethodKind = false; - inAsync: boolean = false; inPipeline: boolean = false; inType: boolean = false; noAnonFunctionType: boolean = false; diff --git a/packages/babel-parser/src/util/scope.js b/packages/babel-parser/src/util/scope.js new file mode 100644 index 0000000000..496814cd96 --- /dev/null +++ b/packages/babel-parser/src/util/scope.js @@ -0,0 +1,160 @@ +// @flow +import { + SCOPE_ARROW, + SCOPE_ASYNC, + SCOPE_DIRECT_SUPER, + SCOPE_FUNCTION, + SCOPE_GENERATOR, + SCOPE_SIMPLE_CATCH, + SCOPE_SUPER, + SCOPE_PROGRAM, + SCOPE_VAR, + BIND_SIMPLE_CATCH, + BIND_LEXICAL, + BIND_FUNCTION, + type ScopeFlags, + type BindingTypes, + SCOPE_CLASS, +} from "./scopeflags"; + +// Start an AST node, attaching a start offset. +class Scope { + flags: ScopeFlags; + // A list of var-declared names in the current lexical scope + var: string[] = []; + // A list of lexically-declared names in the current lexical scope + lexical: string[] = []; + // A list of lexically-declared FunctionDeclaration names in the current lexical scope + functions: string[] = []; + + constructor(flags: ScopeFlags) { + this.flags = flags; + } +} + +type raiseFunction = (number, string) => void; + +// The functions in this module keep track of declared variables in the +// current scope in order to detect duplicate variable names. +export default class ScopeHandler { + scopeStack: Array = []; + raise: raiseFunction; + inModule: boolean; + + constructor(raise: raiseFunction, inModule: boolean) { + this.raise = raise; + this.inModule = inModule; + } + + get inFunction() { + return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0; + } + get inGenerator() { + return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0; + } + get inAsync() { + return (this.currentVarScope().flags & SCOPE_ASYNC) > 0; + } + get allowSuper() { + return (this.currentThisScope().flags & SCOPE_SUPER) > 0; + } + get allowDirectSuper() { + return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0; + } + get inNonArrowFunction() { + return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0; + } + get treatFunctionsAsVar() { + return this.treatFunctionsAsVarInScope(this.currentScope()); + } + + enter(flags: ScopeFlags) { + this.scopeStack.push(new Scope(flags)); + } + + exit() { + this.scopeStack.pop(); + } + + // The spec says: + // > At the top level of a function, or script, function declarations are + // > treated like var declarations rather than like lexical declarations. + treatFunctionsAsVarInScope(scope: Scope): boolean { + return !!( + scope.flags & SCOPE_FUNCTION || + (!this.inModule && scope.flags & SCOPE_PROGRAM) + ); + } + + declareName(name: string, bindingType: ?BindingTypes, pos: number) { + let redeclared = false; + if (bindingType === BIND_LEXICAL) { + const scope = this.currentScope(); + redeclared = + scope.lexical.indexOf(name) > -1 || + scope.functions.indexOf(name) > -1 || + scope.var.indexOf(name) > -1; + scope.lexical.push(name); + } else if (bindingType === BIND_SIMPLE_CATCH) { + const scope = this.currentScope(); + scope.lexical.push(name); + } else if (bindingType === BIND_FUNCTION) { + const scope = this.currentScope(); + if (this.treatFunctionsAsVar) { + redeclared = scope.lexical.indexOf(name) > -1; + } else { + redeclared = + scope.lexical.indexOf(name) > -1 || scope.var.indexOf(name) > -1; + } + scope.functions.push(name); + } else { + for (let i = this.scopeStack.length - 1; i >= 0; --i) { + const scope = this.scopeStack[i]; + if ( + (scope.lexical.indexOf(name) > -1 && + !(scope.flags & SCOPE_SIMPLE_CATCH) && + scope.lexical[0] === name) || + (!this.treatFunctionsAsVarInScope(scope) && + scope.functions.indexOf(name) > -1) + ) { + redeclared = true; + break; + } + scope.var.push(name); + + if (scope.flags & SCOPE_VAR) break; + } + } + if (redeclared) { + this.raise(pos, `Identifier '${name}' has already been declared`); + } + } + + currentScope(): Scope { + return this.scopeStack[this.scopeStack.length - 1]; + } + + // $FlowIgnore + currentVarScope(): Scope { + for (let i = this.scopeStack.length - 1; ; i--) { + const scope = this.scopeStack[i]; + if (scope.flags & SCOPE_VAR) { + return scope; + } + } + } + + // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`. + // $FlowIgnore + currentThisScope(): Scope { + for (let i = this.scopeStack.length - 1; ; i--) { + const scope = this.scopeStack[i]; + if ( + (scope.flags & SCOPE_VAR || scope.flags & SCOPE_CLASS) && + !(scope.flags & SCOPE_ARROW) + ) { + return scope; + } + } + } +} diff --git a/packages/babel-parser/src/util/scopeflags.js b/packages/babel-parser/src/util/scopeflags.js new file mode 100644 index 0000000000..35ba7fe303 --- /dev/null +++ b/packages/babel-parser/src/util/scopeflags.js @@ -0,0 +1,52 @@ +// @flow + +// Each scope gets a bitset that may contain these flags +// prettier-ignore +export const SCOPE_OTHER = 0b000000000, + SCOPE_PROGRAM = 0b000000001, + SCOPE_FUNCTION = 0b000000010, + SCOPE_ASYNC = 0b000000100, + SCOPE_GENERATOR = 0b000001000, + SCOPE_ARROW = 0b000010000, + SCOPE_SIMPLE_CATCH = 0b000100000, + SCOPE_SUPER = 0b001000000, + SCOPE_DIRECT_SUPER = 0b010000000, + SCOPE_CLASS = 0b100000000, + SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION; + +export type ScopeFlags = + | typeof SCOPE_OTHER + | typeof SCOPE_PROGRAM + | typeof SCOPE_FUNCTION + | typeof SCOPE_VAR + | typeof SCOPE_ASYNC + | typeof SCOPE_GENERATOR + | typeof SCOPE_ARROW + | typeof SCOPE_SIMPLE_CATCH + | typeof SCOPE_SUPER + | typeof SCOPE_DIRECT_SUPER + | typeof SCOPE_CLASS; + +export function functionFlags(isAsync: boolean, isGenerator: boolean) { + return ( + SCOPE_FUNCTION | + (isAsync ? SCOPE_ASYNC : 0) | + (isGenerator ? SCOPE_GENERATOR : 0) + ); +} + +// Used in checkLVal and declareName to determine the type of a binding +export const BIND_NONE = 0, // Not a binding + BIND_VAR = 1, // Var-style binding + BIND_LEXICAL = 2, // Let- or const-style binding + BIND_FUNCTION = 3, // Function declaration + BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding + BIND_OUTSIDE = 5; // Special case for function names as bound inside the function + +export type BindingTypes = + | typeof BIND_NONE + | typeof BIND_VAR + | typeof BIND_LEXICAL + | typeof BIND_FUNCTION + | typeof BIND_SIMPLE_CATCH + | typeof BIND_OUTSIDE; diff --git a/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/options.json b/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/options.json index d58bb015bf..12b18792fc 100644 --- a/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/options.json +++ b/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:10)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/options.json b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/options.json index c1cad1bfed..05a7826ae8 100644 --- a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/options.json +++ b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/options.json @@ -1,3 +1,3 @@ { - "throws": "Function declaration not allowed in this context (1:10)" + "throws": "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement (1:10)" } diff --git a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/options.json b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/options.json index 1397e6a762..395620bfa2 100644 --- a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/options.json +++ b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/options.json @@ -1,3 +1,3 @@ { - "throws": "Function declaration not allowed in this context (1:20)" + "throws": "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement (1:20)" } diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/input.js new file mode 100644 index 0000000000..0ed8680e48 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/input.js @@ -0,0 +1,3 @@ +try { +} catch ([foo, foo]) { +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/options.json new file mode 100644 index 0000000000..70121ca46e --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:15)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/input.js new file mode 100644 index 0000000000..5ccd99323a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/input.js @@ -0,0 +1 @@ +let foo; try {} catch (foo) {} let foo; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/options.json new file mode 100644 index 0000000000..386e81ecdc --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (1:35)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/input.js new file mode 100644 index 0000000000..c53b6b3d03 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/input.js @@ -0,0 +1,4 @@ +try { +} catch (foo) { + function foo() {} +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/options.json new file mode 100644 index 0000000000..62b0c73eb1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (3:11)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/input.js new file mode 100644 index 0000000000..32d85119a5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/input.js @@ -0,0 +1,4 @@ +try { +} catch (foo) { + if (1) function foo() {} +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/output.json new file mode 100644 index 0000000000..b576780b70 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/output.json @@ -0,0 +1,207 @@ +{ + "type": "File", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "param": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 20, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "IfStatement", + "start": 24, + "end": 48, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "test": { + "type": "NumericLiteral", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "consequent": { + "type": "FunctionDeclaration", + "start": 31, + "end": 48, + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 40, + "end": 43, + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 21 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 46, + "end": 48, + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "body": [], + "directives": [] + } + }, + "alternate": null + } + ], + "directives": [] + } + }, + "guardedHandlers": [], + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/input.js new file mode 100644 index 0000000000..f223972849 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/input.js @@ -0,0 +1,4 @@ +try { +} catch (foo) { +} +let foo; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/output.json new file mode 100644 index 0000000000..677fad5fcd --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/output.json @@ -0,0 +1,169 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "param": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [] + } + }, + "guardedHandlers": [], + "finalizer": null + }, + { + "type": "VariableDeclaration", + "start": 24, + "end": 32, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/input.js new file mode 100644 index 0000000000..8e4af00ffa --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/input.js @@ -0,0 +1,4 @@ +try { +} catch (foo) { + let foo; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/options.json new file mode 100644 index 0000000000..254a763e65 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (3:6)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/input.js new file mode 100644 index 0000000000..b8a800685a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/input.js @@ -0,0 +1,3 @@ +try { +} catch ({ a: foo, b: { c: [foo] } }) { +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/options.json new file mode 100644 index 0000000000..a00c2989e1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:28)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/input.js new file mode 100644 index 0000000000..0c5630af7e --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/input.js @@ -0,0 +1,4 @@ +try { +} catch ([foo]) { + var foo; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/options.json new file mode 100644 index 0000000000..ff69adb086 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (3:6)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/input.js new file mode 100644 index 0000000000..6cdcb267c2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/input.js @@ -0,0 +1,7 @@ +try { +} catch (foo) { + try { + } catch (_) { + var foo; + } +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/output.json new file mode 100644 index 0000000000..6b4c229346 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/output.json @@ -0,0 +1,254 @@ +{ + "type": "File", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 64, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "param": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 20, + "end": 64, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "body": [ + { + "type": "TryStatement", + "start": 24, + "end": 62, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "block": { + "type": "BlockStatement", + "start": 28, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 34, + "end": 62, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "param": { + "type": "Identifier", + "start": 41, + "end": 42, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 12 + }, + "identifierName": "_" + }, + "name": "_" + }, + "body": { + "type": "BlockStatement", + "start": 44, + "end": 62, + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 50, + "end": 58, + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 54, + "end": 57, + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 54, + "end": 57, + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 11 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } + }, + "guardedHandlers": [], + "finalizer": null + } + ], + "directives": [] + } + }, + "guardedHandlers": [], + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/input.js new file mode 100644 index 0000000000..a93f6a37bd --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/input.js @@ -0,0 +1,4 @@ +try { +} catch ({ foo }) { + var foo; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/options.json new file mode 100644 index 0000000000..ff69adb086 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (3:6)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/input.js new file mode 100644 index 0000000000..cd2df99649 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/input.js @@ -0,0 +1,4 @@ +try { +} catch (foo) { +} +var foo; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/output.json new file mode 100644 index 0000000000..439f7f105f --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/output.json @@ -0,0 +1,169 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "param": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [] + } + }, + "guardedHandlers": [], + "finalizer": null + }, + { + "type": "VariableDeclaration", + "start": 24, + "end": 32, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/input.js new file mode 100644 index 0000000000..e2983d96dc --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/input.js @@ -0,0 +1,4 @@ +try { +} catch (foo) { + var foo; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/output.json new file mode 100644 index 0000000000..66d668784c --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/output.json @@ -0,0 +1,170 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "param": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 20, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 24, + "end": 32, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } + }, + "guardedHandlers": [], + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/input.js new file mode 100644 index 0000000000..3996f21e12 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/input.js @@ -0,0 +1,2 @@ +class foo {}; +class foo {}; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/options.json new file mode 100644 index 0000000000..cdd0ac832c --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:6)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/input.js new file mode 100644 index 0000000000..0f7aaf2b69 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/input.js @@ -0,0 +1,2 @@ +class foo {}; +const foo = 1; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/options.json new file mode 100644 index 0000000000..c45b9bf382 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:6)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/input.js new file mode 100644 index 0000000000..0953b37d0c --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/input.js @@ -0,0 +1,2 @@ +class foo {}; +function foo () {}; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/options.json new file mode 100644 index 0000000000..58aaf9d99d --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:9)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/input.js new file mode 100644 index 0000000000..970f577a71 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/input.js @@ -0,0 +1,2 @@ +class foo {}; +let foo = 1; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/options.json new file mode 100644 index 0000000000..bf89e4692c --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:4)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/input.js new file mode 100644 index 0000000000..0cbd916cdb --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/input.js @@ -0,0 +1,2 @@ +class foo {}; +var foo; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/options.json new file mode 100644 index 0000000000..bf89e4692c --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:4)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/input.js new file mode 100644 index 0000000000..206de74b49 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/input.js @@ -0,0 +1 @@ +const foo=1, foo=2; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/options.json new file mode 100644 index 0000000000..d62aabfd1b --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (1:13)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/input.js new file mode 100644 index 0000000000..b5a6ac21d8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/input.js @@ -0,0 +1 @@ +{ function f() {} function* f() {} } diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/options.json new file mode 100644 index 0000000000..c083e3d4c0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'f' has already been declared (1:28)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/input.js new file mode 100644 index 0000000000..31ea14cffb --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/input.js @@ -0,0 +1 @@ +{ function foo() {} function foo() {} } diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/options.json new file mode 100644 index 0000000000..3f4250fbe9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "throws": "Identifier 'foo' has already been declared (1:29)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/input.js new file mode 100644 index 0000000000..11a6da2a7e --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/input.js @@ -0,0 +1,2 @@ +function foo() {} +function foo() {} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/options.json new file mode 100644 index 0000000000..23553cce37 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "throws":"Identifier 'foo' has already been declared (2:9)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/input.js new file mode 100644 index 0000000000..31ea14cffb --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/input.js @@ -0,0 +1 @@ +{ function foo() {} function foo() {} } diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/options.json new file mode 100644 index 0000000000..b412ffe671 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "script" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/output.json new file mode 100644 index 0000000000..94ae24d249 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/output.json @@ -0,0 +1,157 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 2, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 20, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 35, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/input.js new file mode 100644 index 0000000000..11a6da2a7e --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/input.js @@ -0,0 +1,2 @@ +function foo() {} +function foo() {} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/options.json new file mode 100644 index 0000000000..b412ffe671 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "script" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/output.json new file mode 100644 index 0000000000..af377ce804 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/output.json @@ -0,0 +1,139 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 18, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 27, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 33, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/input.js new file mode 100644 index 0000000000..7f32f625bc --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/input.js @@ -0,0 +1,4 @@ +{ + function foo() {} + var foo = 1; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/options.json new file mode 100644 index 0000000000..ff69adb086 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (3:6)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/input.js new file mode 100644 index 0000000000..3248c1cf45 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/input.js @@ -0,0 +1,2 @@ +function foo() {} +var foo = 1; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/output.json new file mode 100644 index 0000000000..d2a2c6f998 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/output.json @@ -0,0 +1,157 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "VariableDeclaration", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 22, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/input.js new file mode 100644 index 0000000000..cc9c094667 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/input.js @@ -0,0 +1 @@ +{ function* f() {} function f() {} } diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/options.json new file mode 100644 index 0000000000..c083e3d4c0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'f' has already been declared (1:28)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/input.js new file mode 100644 index 0000000000..a43e0c8581 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/input.js @@ -0,0 +1,2 @@ +function *foo() {}; +function *foo() {}; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/options.json new file mode 100644 index 0000000000..b412ffe671 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "script" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/output.json new file mode 100644 index 0000000000..e5bce9fb21 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/output.json @@ -0,0 +1,169 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "EmptyStatement", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + } + }, + { + "type": "FunctionDeclaration", + "start": 20, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 36, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "EmptyStatement", + "start": 38, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/input.js new file mode 100644 index 0000000000..60494395b6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/input.js @@ -0,0 +1 @@ +let foo, foo; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/options.json new file mode 100644 index 0000000000..714354e145 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (1:9)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/input.js new file mode 100644 index 0000000000..79a65c0ee2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/input.js @@ -0,0 +1,4 @@ +{ + let a; + { var a; } +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/options.json new file mode 100644 index 0000000000..a0925d4956 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'a' has already been declared (3:8)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/input.js new file mode 100644 index 0000000000..b5bbb6d441 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/input.js @@ -0,0 +1,4 @@ +{ + var a; + { let a; } +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/output.json new file mode 100644 index 0000000000..239db26973 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/output.json @@ -0,0 +1,173 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": null + } + ], + "kind": "var" + }, + { + "type": "BlockStatement", + "start": 13, + "end": 23, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/input.js new file mode 100644 index 0000000000..260da8ced8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/input.js @@ -0,0 +1 @@ +var foo, foo; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/output.json new file mode 100644 index 0000000000..0be8a0eea2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + }, + { + "type": "VariableDeclarator", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/let-assign/input.js b/packages/babel-parser/test/fixtures/core/scope/let-assign/input.js new file mode 100644 index 0000000000..a66eb5ab67 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/let-assign/input.js @@ -0,0 +1 @@ +let x = 1; x = 2; diff --git a/packages/babel-parser/test/fixtures/core/scope/let-assign/output.json b/packages/babel-parser/test/fixtures/core/scope/let-assign/output.json new file mode 100644 index 0000000000..508af9fc85 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/let-assign/output.json @@ -0,0 +1,173 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + }, + { + "type": "ExpressionStatement", + "start": 11, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "NumericLiteral", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/401/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/401/options.json index 2a28555f76..fa57d4f43f 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/401/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/401/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Unexpected keyword 'null' (1:9)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/402/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/402/options.json index 2a28555f76..c4a7ead137 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/402/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/402/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Unexpected keyword 'true' (1:9)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/403/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/403/options.json index 2a28555f76..0e9cf8962a 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/403/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/403/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Unexpected keyword 'false' (1:9)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/404/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/404/options.json index 2a28555f76..a87aa98c0e 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/404/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/404/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Unexpected keyword 'if' (1:9)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/514/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/514/options.json index e23388601b..8b20b9a7df 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/514/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/514/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:14)" + "throws": "Argument name clash (1:14)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/517/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/517/options.json index 660e54ca2a..9d2a580815 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/517/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/517/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:43)" + "throws": "Argument name clash (1:43)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/518/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/518/options.json index 28545ded14..61c3bbb5ab 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/518/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/518/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:15)" + "throws": "Argument name clash (1:15)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/519/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/519/options.json index 0f592c74a3..ae469fbd59 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/519/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/519/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:44)" + "throws": "Argument name clash (1:44)" } diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json b/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json index faef53359b..9461325c42 100644 --- a/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json +++ b/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json @@ -1,3 +1,3 @@ { - "throws": "super() is only valid inside a class constructor. Make sure the method name is spelled exactly as 'constructor'. (2:8)" + "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (2:8)" } diff --git a/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/input.js b/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/input.js new file mode 100644 index 0000000000..b6864d7c33 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/input.js @@ -0,0 +1 @@ +if (1) function *foo() {} diff --git a/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/options.json b/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/options.json new file mode 100644 index 0000000000..8cdac51705 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Generators can only be declared at the top level or inside a block (1:16)" +} diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/expression/input.js b/packages/babel-parser/test/fixtures/es2015/meta-properties/expression/input.js new file mode 100644 index 0000000000..932ee841bd --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/expression/input.js @@ -0,0 +1,3 @@ +const A = function() { + new.target; +}; diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/expression/output.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/expression/output.json new file mode 100644 index 0000000000..f5f3e41b51 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/expression/output.json @@ -0,0 +1,186 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "FunctionExpression", + "start": 10, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 21, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 25, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "expression": { + "type": "MetaProperty", + "start": 25, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "meta": { + "type": "Identifier", + "start": 25, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 29, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "target" + }, + "name": "target" + } + } + } + ], + "directives": [] + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/input.js b/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/input.js new file mode 100644 index 0000000000..f13bdd7175 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/input.js @@ -0,0 +1,3 @@ +const A = () => { + new.target; +} diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/options.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/options.json new file mode 100644 index 0000000000..4be1533d8e --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/options.json @@ -0,0 +1,3 @@ +{ + "throws": "new.target can only be used in functions (2:2)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/input.js b/packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/input.js new file mode 100644 index 0000000000..a3f74c60f1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/input.js @@ -0,0 +1 @@ +function A() { return () => new.target } diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/output.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/output.json new file mode 100644 index 0000000000..447bc2741c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/output.json @@ -0,0 +1,171 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "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": 1, + "column": 40 + } + }, + "body": [ + { + "type": "ReturnStatement", + "start": 15, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "argument": { + "type": "ArrowFunctionExpression", + "start": 22, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "MetaProperty", + "start": 28, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "meta": { + "type": "Identifier", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + }, + "identifierName": "target" + }, + "name": "target" + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/statement/input.js b/packages/babel-parser/test/fixtures/es2015/meta-properties/statement/input.js new file mode 100644 index 0000000000..ecd7c772f6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/statement/input.js @@ -0,0 +1,3 @@ +function A() { + new.target; +} diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/statement/output.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/statement/output.json new file mode 100644 index 0000000000..80af5ec9a8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/statement/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "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": 30, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 17, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "expression": { + "type": "MetaProperty", + "start": 17, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "meta": { + "type": "Identifier", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "target" + }, + "name": "target" + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/options.json index c8c111d88d..446a980f54 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:20)" + "throws": "Identifier 'foo' has already been declared (2:20)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/options.json index cf1dcd59dc..09b3fa97a0 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo4` has already been exported. Exported identifiers must be unique. (2:50)" + "throws": "Identifier 'foo4' has already been declared (2:50)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/options.json index c2f8cdda98..3a7173c837 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo4` has already been exported. Exported identifiers must be unique. (2:49)" + "throws": "Identifier 'foo4' has already been declared (2:49)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/options.json index 1cd229e76c..d3fc42a61b 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo4` has already been exported. Exported identifiers must be unique. (2:58)" + "throws": "Identifier 'foo4' has already been declared (2:58)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/options.json index e6aaa311fc..80640e0ce1 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:21)" + "throws": "Identifier 'foo' has already been declared (2:21)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/options.json index 4eb6f26f95..ea3a9b62f4 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo2` has already been exported. Exported identifiers must be unique. (2:13)" + "throws": "Identifier 'foo2' has already been declared (2:13)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/options.json index 4f3ba9d9d2..42c862ad27 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:22)" + "throws": "Identifier 'foo' has already been declared (2:22)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/options.json index dab0e075b0..125c261843 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/options.json @@ -1,3 +1,3 @@ { - "throws": "`bar` has already been exported. Exported identifiers must be unique. (2:13)" + "throws": "Identifier 'bar' has already been declared (2:13)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/options.json index 7ee0cc4341..bf345ea771 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:28)" + "throws": "Identifier 'foo' has already been declared (2:28)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/options.json index 72b54a0a77..bf24833621 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:29)" + "throws": "Identifier 'foo' has already been declared (2:29)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/options.json index f28333f6f8..2cbe06c409 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:15)" + "throws": "Identifier 'foo' has already been declared (2:15)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/options.json index 1923e47523..d363903569 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:0)" + "throws": "Identifier 'foo' has already been declared (2:16)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/options.json index 37d131b70f..4635849358 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:14)" + "throws": "Identifier 'foo' has already been declared (2:14)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/options.json index 1923e47523..d363903569 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:0)" + "throws": "Identifier 'foo' has already been declared (2:16)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/options.json index 37d131b70f..4635849358 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:14)" + "throws": "Identifier 'foo' has already been declared (2:14)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/options.json index f28333f6f8..2cbe06c409 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:15)" + "throws": "Identifier 'foo' has already been declared (2:15)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/options.json index 8ef246d83c..982078d803 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/options.json @@ -1,3 +1,3 @@ { - "throws": "`Foo` has already been exported. Exported identifiers must be unique. (2:15)" + "throws": "Identifier 'Foo' has already been declared (2:15)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/options.json index 6b46482b6e..f79b5469b1 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/options.json @@ -1,3 +1,3 @@ { - "throws": "`Foo` has already been exported. Exported identifiers must be unique. (2:14)" + "throws": "Identifier 'Foo' has already been declared (2:14)" } diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/options.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/options.json index 91b308200e..a064a678e5 100644 --- a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/options.json +++ b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:5)" + "throws": "Lexical declaration cannot appear in a single-statement context (1:5)" } diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/options.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/options.json index 042d7e1962..95aaacb458 100644 --- a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/options.json +++ b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/options.json @@ -1,3 +1,3 @@ { - "throws": "Function declaration not allowed in this context (1:5)" + "throws": "Async functions can only be declared at the top level or inside a block (1:5)" } diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/options.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/options.json index 91b308200e..3f6e90c7cd 100644 --- a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/options.json +++ b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:5)" + "throws": "Generators can only be declared at the top level or inside a block (1:13)" } diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/options.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/options.json index ee5cd5b135..1eebe15c40 100644 --- a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/options.json +++ b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/options.json @@ -1,3 +1,3 @@ { - "throws": "Function declaration not allowed in this context (1:35)" + "throws": "In strict mode code, functions can only be declared at top level or inside a block (1:35)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/123/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/123/options.json new file mode 100644 index 0000000000..fdf74cefe1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/123/options.json @@ -0,0 +1,3 @@ +{ + "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (1:40)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/123/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/123/output.json deleted file mode 100644 index 56f49a7b69..0000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/123/output.json +++ /dev/null @@ -1,243 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 51, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 51 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 51, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 51 - } - }, - "sourceType": "script", - "interpreter": null, - "body": [ - { - "type": "ExpressionStatement", - "start": 14, - "end": 51, - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 51 - } - }, - "expression": { - "type": "ClassExpression", - "start": 15, - "end": 50, - "loc": { - "start": { - "line": 1, - "column": 15 - }, - "end": { - "line": 1, - "column": 50 - } - }, - "id": { - "type": "Identifier", - "start": 21, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 21 - }, - "end": { - "line": 1, - "column": 22 - }, - "identifierName": "A" - }, - "name": "A" - }, - "superClass": null, - "body": { - "type": "ClassBody", - "start": 23, - "end": 50, - "loc": { - "start": { - "line": 1, - "column": 23 - }, - "end": { - "line": 1, - "column": 50 - } - }, - "body": [ - { - "type": "ClassMethod", - "start": 24, - "end": 49, - "loc": { - "start": { - "line": 1, - "column": 24 - }, - "end": { - "line": 1, - "column": 49 - } - }, - "static": false, - "key": { - "type": "Identifier", - "start": 24, - "end": 35, - "loc": { - "start": { - "line": 1, - "column": 24 - }, - "end": { - "line": 1, - "column": 35 - }, - "identifierName": "constructor" - }, - "name": "constructor" - }, - "computed": false, - "kind": "constructor", - "id": null, - "generator": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 38, - "end": 49, - "loc": { - "start": { - "line": 1, - "column": 38 - }, - "end": { - "line": 1, - "column": 49 - } - }, - "body": [ - { - "type": "ExpressionStatement", - "start": 40, - "end": 47, - "loc": { - "start": { - "line": 1, - "column": 40 - }, - "end": { - "line": 1, - "column": 47 - } - }, - "expression": { - "type": "CallExpression", - "start": 40, - "end": 47, - "loc": { - "start": { - "line": 1, - "column": 40 - }, - "end": { - "line": 1, - "column": 47 - } - }, - "callee": { - "type": "Super", - "start": 40, - "end": 45, - "loc": { - "start": { - "line": 1, - "column": 40 - }, - "end": { - "line": 1, - "column": 45 - } - } - }, - "arguments": [] - } - } - ], - "directives": [] - } - } - ] - }, - "extra": { - "parenthesized": true, - "parenStart": 14 - } - } - } - ], - "directives": [ - { - "type": "Directive", - "start": 0, - "end": 13, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, - "value": { - "type": "DirectiveLiteral", - "start": 0, - "end": 12, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "value": "use strict", - "extra": { - "raw": "\"use strict\"", - "rawValue": "use strict" - } - } - } - ] - } -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/166/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/166/options.json new file mode 100644 index 0000000000..3481bedf3c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/166/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Argument name clash (1:16)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/166/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/166/output.json deleted file mode 100644 index 8f278a52ae..0000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/166/output.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } - }, - "sourceType": "script", - "interpreter": null, - "body": [ - { - "type": "FunctionDeclaration", - "start": 0, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } - }, - "id": { - "type": "Identifier", - "start": 9, - "end": 10, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 10 - }, - "identifierName": "x" - }, - "name": "x" - }, - "generator": false, - "async": false, - "params": [ - { - "type": "Identifier", - "start": 11, - "end": 12, - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 12 - }, - "identifierName": "a" - }, - "name": "a" - }, - { - "type": "ObjectPattern", - "start": 14, - "end": 19, - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 19 - } - }, - "properties": [ - { - "type": "ObjectProperty", - "start": 16, - "end": 17, - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 17 - } - }, - "method": false, - "key": { - "type": "Identifier", - "start": 16, - "end": 17, - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 17 - }, - "identifierName": "a" - }, - "name": "a" - }, - "computed": false, - "shorthand": true, - "value": { - "type": "Identifier", - "start": 16, - "end": 17, - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 17 - }, - "identifierName": "a" - }, - "name": "a" - }, - "extra": { - "shorthand": true - } - } - ] - } - ], - "body": { - "type": "BlockStatement", - "start": 20, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 20 - }, - "end": { - "line": 1, - "column": 22 - } - }, - "body": [], - "directives": [] - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/226/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/226/options.json index 2a28555f76..74c1a72d50 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/226/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/226/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Unexpected keyword 'default' (1:9)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/228/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/228/options.json index 9f34dba232..a33dde4690 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/228/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/228/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:37)" + "throws": "Argument name clash (1:37)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/248/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/248/options.json index 6d0445e20e..b99fd35222 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/248/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/248/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:18)" + "throws": "Argument name clash (1:18)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/280/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/280/options.json index 0c0a9d0136..5cbee309bd 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/280/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/280/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:30)" + "throws": "Argument name clash (1:30)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/281/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/281/options.json index 4773c60e5b..8dba9882c0 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/281/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/281/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:47)" + "throws": "Argument name clash (1:47)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/329/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/329/options.json index 2a28555f76..97818d2eea 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/329/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/329/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Lexical declaration cannot appear in a single-statement context (1:9)" } diff --git a/packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/input.js b/packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/input.js new file mode 100644 index 0000000000..c1ce97544c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/input.js @@ -0,0 +1,9 @@ +var yieldSet, C, iter; +function* g() { + class C_ { + get [yield]() { return 'get yield'; } + set [yield](param) { yieldSet = param; } + } + + C = C_; +} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/output.json b/packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/output.json new file mode 100644 index 0000000000..1082894c21 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/output.json @@ -0,0 +1,552 @@ +{ + "type": "File", + "start": 0, + "end": 155, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 155, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "yieldSet" + }, + "name": "yieldSet" + }, + "init": null + }, + { + "type": "VariableDeclarator", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "id": { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "C" + }, + "name": "C" + }, + "init": null + }, + { + "type": "VariableDeclarator", + "start": 17, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "iter" + }, + "name": "iter" + }, + "init": null + } + ], + "kind": "var" + }, + { + "type": "FunctionDeclaration", + "start": 23, + "end": 155, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 33, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 37, + "end": 155, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "start": 41, + "end": 142, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 47, + "end": 49, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 10 + }, + "identifierName": "C_" + }, + "name": "C_" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 50, + "end": 142, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 56, + "end": 93, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 41 + } + }, + "static": false, + "key": { + "type": "YieldExpression", + "start": 61, + "end": 66, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "delegate": false, + "argument": null + }, + "computed": true, + "kind": "get", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 70, + "end": 93, + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 41 + } + }, + "body": [ + { + "type": "ReturnStatement", + "start": 72, + "end": 91, + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 39 + } + }, + "argument": { + "type": "StringLiteral", + "start": 79, + "end": 90, + "loc": { + "start": { + "line": 4, + "column": 27 + }, + "end": { + "line": 4, + "column": 38 + } + }, + "extra": { + "rawValue": "get yield", + "raw": "'get yield'" + }, + "value": "get yield" + } + } + ], + "directives": [] + } + }, + { + "type": "ClassMethod", + "start": 98, + "end": 138, + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 44 + } + }, + "static": false, + "key": { + "type": "YieldExpression", + "start": 103, + "end": 108, + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "delegate": false, + "argument": null + }, + "computed": true, + "kind": "set", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 110, + "end": 115, + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 21 + }, + "identifierName": "param" + }, + "name": "param" + } + ], + "body": { + "type": "BlockStatement", + "start": 117, + "end": 138, + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 44 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 119, + "end": 136, + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 42 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 119, + "end": 135, + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 41 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 119, + "end": 127, + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 33 + }, + "identifierName": "yieldSet" + }, + "name": "yieldSet" + }, + "right": { + "type": "Identifier", + "start": 130, + "end": 135, + "loc": { + "start": { + "line": 5, + "column": 36 + }, + "end": { + "line": 5, + "column": 41 + }, + "identifierName": "param" + }, + "name": "param" + } + } + } + ], + "directives": [] + } + } + ] + } + }, + { + "type": "ExpressionStatement", + "start": 146, + "end": 153, + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 146, + "end": 152, + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 146, + "end": 147, + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 3 + }, + "identifierName": "C" + }, + "name": "C" + }, + "right": { + "type": "Identifier", + "start": 150, + "end": 152, + "loc": { + "start": { + "line": 8, + "column": 6 + }, + "end": { + "line": 8, + "column": 8 + }, + "identifierName": "C_" + }, + "name": "C_" + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/options.json index 5a257f4e5d..12b18792fc 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:11)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/options.json index 5a257f4e5d..12b18792fc 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:11)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/options.json index 2e6ae0771c..089b542c37 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:9)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:8)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/options.json index 0c31636171..089b542c37 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:15)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:8)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/options.json index ff8a46ae1a..12b18792fc 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:17)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/options.json index 5a257f4e5d..12b18792fc 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:11)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/options.json index 65ff709b5f..12b18792fc 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:12)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/options.json index dd467e6578..9908b496fd 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (2:6)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (2:5)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/options.json index ac620235e9..5d0e394f2b 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (2:4)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (2:3)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/options.json index 5a257f4e5d..12b18792fc 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:11)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/options.json index 5a257f4e5d..12b18792fc 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:11)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/options.json index 5a257f4e5d..12b18792fc 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:11)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/options.json index c1cad1bfed..4bcd823e98 100644 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/options.json +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/options.json @@ -1,3 +1,3 @@ { - "throws": "Function declaration not allowed in this context (1:10)" + "throws": "Async functions can only be declared at the top level or inside a block (1:10)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/options.json index b382a06ac5..6dad74eebd 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:23)" + "throws": "Identifier 'foo' has already been declared (2:23)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/options.json index d6149ed845..165223a448 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "`bar` has already been exported. Exported identifiers must be unique. (2:13)" + "throws": "Identifier 'bar' has already been declared (2:13)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/options.json index 8daa306ff7..68df28e41c 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:30)" + "throws": "Identifier 'foo' has already been declared (2:30)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/options.json index a87b46d55a..280073b140 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:29)" + "throws": "Identifier 'foo' has already been declared (2:29)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/options.json index 8daa306ff7..68df28e41c 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:30)" + "throws": "Identifier 'foo' has already been declared (2:30)" } diff --git a/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/options.json b/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/options.json index e23388601b..8b20b9a7df 100644 --- a/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/options.json +++ b/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:14)" + "throws": "Argument name clash (1:14)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/options.json index 34197d2efe..a4a6e207d2 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:11)" + "throws": "Argument name clash (1:11)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/options.json index d498cd8bd0..49e8d8e863 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (2:14)" + "throws": "Argument name clash (2:14)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/options.json index e3176a8e57..3829082a48 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (2:17)" + "throws": "Argument name clash (2:17)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/options.json index 2d74a95450..782073313a 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (2:19)" + "throws": "Argument name clash (2:19)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/input.js deleted file mode 100644 index 417d6fc849..0000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/input.js +++ /dev/null @@ -1 +0,0 @@ -try {} catch ([a,a]) {} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/options.json deleted file mode 100644 index 7d5bec6e9b..0000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash in strict mode (1:17)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/options.json index 4ebe77e8fc..fd74c52285 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:7)" + "throws": "Argument name clash (1:7)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/options.json index 0590c2b7e6..368006ae58 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:4)" + "throws": "Argument name clash (1:4)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/options.json index 0590c2b7e6..368006ae58 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:4)" + "throws": "Argument name clash (1:4)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/options.json index 6d0445e20e..b99fd35222 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:18)" + "throws": "Argument name clash (1:18)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/options.json index 2a28555f76..97818d2eea 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Lexical declaration cannot appear in a single-statement context (1:9)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/options.json index e23388601b..8b20b9a7df 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:14)" + "throws": "Argument name clash (1:14)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/options.json index 660e54ca2a..9d2a580815 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:43)" + "throws": "Argument name clash (1:43)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/options.json index 28545ded14..61c3bbb5ab 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:15)" + "throws": "Argument name clash (1:15)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/options.json index 0f592c74a3..ae469fbd59 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:44)" + "throws": "Argument name clash (1:44)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/options.json index 172760cf2c..505798d5a2 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:36)" + "throws": "Argument name clash (1:36)" } diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/options.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/options.json index e20043c3fa..2154c844bf 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/options.json @@ -1,4 +1,4 @@ { "plugins": ["classPrivateProperties"], - "throws": "super() is only valid inside a class constructor. Make sure the method name is spelled exactly as 'constructor'. (4:13)" + "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (4:13)" } diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/options.json b/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/options.json index 3f06e4fecf..e8d509e277 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/options.json @@ -1,4 +1,4 @@ { "plugins": ["classProperties"], - "throws": "super() is only valid inside a class constructor. Make sure the method name is spelled exactly as 'constructor'. (4:12)" + "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (4:12)" } diff --git a/packages/babel-parser/test/fixtures/flow/declare-statements/15/input.js b/packages/babel-parser/test/fixtures/flow/declare-statements/15/input.js index e5d2353e55..63a4ecdb5b 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-statements/15/input.js +++ b/packages/babel-parser/test/fixtures/flow/declare-statements/15/input.js @@ -1,2 +1,2 @@ declare interface I { foo: string } -declare interface I { foo: T } +declare interface I2 { foo: T } diff --git a/packages/babel-parser/test/fixtures/flow/declare-statements/15/output.json b/packages/babel-parser/test/fixtures/flow/declare-statements/15/output.json index 6af031abc6..619a44a76f 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-statements/15/output.json +++ b/packages/babel-parser/test/fixtures/flow/declare-statements/15/output.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 69, + "end": 70, "loc": { "start": { "line": 1, @@ -9,13 +9,13 @@ }, "end": { "line": 2, - "column": 33 + "column": 34 } }, "program": { "type": "Program", "start": 0, - "end": 69, + "end": 70, "loc": { "start": { "line": 1, @@ -23,7 +23,7 @@ }, "end": { "line": 2, - "column": 33 + "column": 34 } }, "sourceType": "module", @@ -142,7 +142,7 @@ { "type": "DeclareInterface", "start": 36, - "end": 69, + "end": 70, "loc": { "start": { "line": 2, @@ -150,13 +150,13 @@ }, "end": { "line": 2, - "column": 33 + "column": 34 } }, "id": { "type": "Identifier", "start": 54, - "end": 55, + "end": 56, "loc": { "start": { "line": 2, @@ -164,39 +164,39 @@ }, "end": { "line": 2, - "column": 19 + "column": 20 }, - "identifierName": "I" + "identifierName": "I2" }, - "name": "I" + "name": "I2" }, "typeParameters": { "type": "TypeParameterDeclaration", - "start": 55, - "end": 58, + "start": 56, + "end": 59, "loc": { "start": { "line": 2, - "column": 19 + "column": 20 }, "end": { "line": 2, - "column": 22 + "column": 23 } }, "params": [ { "type": "TypeParameter", - "start": 56, - "end": 57, + "start": 57, + "end": 58, "loc": { "start": { "line": 2, - "column": 20 + "column": 21 }, "end": { "line": 2, - "column": 21 + "column": 22 } }, "name": "T", @@ -209,46 +209,46 @@ "mixins": [], "body": { "type": "ObjectTypeAnnotation", - "start": 59, - "end": 69, + "start": 60, + "end": 70, "loc": { "start": { "line": 2, - "column": 23 + "column": 24 }, "end": { "line": 2, - "column": 33 + "column": 34 } }, "callProperties": [], "properties": [ { "type": "ObjectTypeProperty", - "start": 61, - "end": 67, + "start": 62, + "end": 68, "loc": { "start": { "line": 2, - "column": 25 + "column": 26 }, "end": { "line": 2, - "column": 31 + "column": 32 } }, "key": { "type": "Identifier", - "start": 61, - "end": 64, + "start": 62, + "end": 65, "loc": { "start": { "line": 2, - "column": 25 + "column": 26 }, "end": { "line": 2, - "column": 28 + "column": 29 }, "identifierName": "foo" }, @@ -260,31 +260,31 @@ "method": false, "value": { "type": "GenericTypeAnnotation", - "start": 66, - "end": 67, + "start": 67, + "end": 68, "loc": { "start": { "line": 2, - "column": 30 + "column": 31 }, "end": { "line": 2, - "column": 31 + "column": 32 } }, "typeParameters": null, "id": { "type": "Identifier", - "start": 66, - "end": 67, + "start": 67, + "end": 68, "loc": { "start": { "line": 2, - "column": 30 + "column": 31 }, "end": { "line": 2, - "column": 31 + "column": 32 }, "identifierName": "T" }, diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/input.js new file mode 100644 index 0000000000..6165683a91 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/input.js @@ -0,0 +1,2 @@ +const A = 1; +declare class A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/options.json new file mode 100644 index 0000000000..4a1b4e5c5c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:14)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/input.js new file mode 100644 index 0000000000..c432acb46b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/input.js @@ -0,0 +1,2 @@ +const A = 1; +declare interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/options.json new file mode 100644 index 0000000000..187fea591b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:18)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/input.js new file mode 100644 index 0000000000..a03017e55c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/input.js @@ -0,0 +1,2 @@ +const A = 1; +interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/options.json new file mode 100644 index 0000000000..04242bd156 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:10)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-class/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-class/input.js new file mode 100644 index 0000000000..32acf9e66e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-class/input.js @@ -0,0 +1,2 @@ +declare class A {} +declare class A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/input.js new file mode 100644 index 0000000000..99bf153061 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/input.js @@ -0,0 +1,2 @@ +declare class A {} +declare interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/options.json new file mode 100644 index 0000000000..187fea591b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:18)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/input.js new file mode 100644 index 0000000000..c3a6f63af3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/input.js @@ -0,0 +1,2 @@ +declare function A(): void; +declare function A(): void; diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/output.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/output.json new file mode 100644 index 0000000000..c4c86f1991 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/output.json @@ -0,0 +1,197 @@ +{ + "type": "File", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareFunction", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "A" + }, + "name": "A", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 18, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "typeAnnotation": { + "type": "FunctionTypeAnnotation", + "start": 18, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "typeParameters": null, + "params": [], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 22, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 26 + } + } + } + } + } + }, + "predicate": null + }, + { + "type": "DeclareFunction", + "start": 28, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 45, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 26 + }, + "identifierName": "A" + }, + "name": "A", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 46, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "typeAnnotation": { + "type": "FunctionTypeAnnotation", + "start": 46, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "typeParameters": null, + "params": [], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 50, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 26 + } + } + } + } + } + }, + "predicate": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/input.js new file mode 100644 index 0000000000..e1e2e647fa --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/input.js @@ -0,0 +1,2 @@ +declare function A(): void; +declare var A: number; diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/options.json new file mode 100644 index 0000000000..81dc2c9079 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:12)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/input.js new file mode 100644 index 0000000000..ccce4b5109 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/input.js @@ -0,0 +1,2 @@ +declare function A(): void; +function A() {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/options.json new file mode 100644 index 0000000000..5f6027f8dd --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:9)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/input.js new file mode 100644 index 0000000000..58df0295d8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/input.js @@ -0,0 +1,2 @@ +declare function A(): number; +let A; diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/options.json new file mode 100644 index 0000000000..b6ff3a4b09 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:4)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/input.js new file mode 100644 index 0000000000..ab4fe6e51f --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/input.js @@ -0,0 +1,2 @@ +declare interface A {} +declare class A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/options.json new file mode 100644 index 0000000000..4a1b4e5c5c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:14)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/input.js new file mode 100644 index 0000000000..7e5419c9a6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/input.js @@ -0,0 +1,2 @@ +declare var A: number; +declare var A: number; diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/output.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/output.json new file mode 100644 index 0000000000..532ca8848c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/output.json @@ -0,0 +1,159 @@ +{ + "type": "File", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareVariable", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 12, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "A" + }, + "name": "A", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 13, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + } + } + } + } + }, + { + "type": "DeclareVariable", + "start": 23, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 35, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 21 + }, + "identifierName": "A" + }, + "name": "A", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 36, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 38, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 21 + } + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/input.js new file mode 100644 index 0000000000..8e72793146 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/input.js @@ -0,0 +1,2 @@ +declare var A: number; +let A; diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/options.json new file mode 100644 index 0000000000..b6ff3a4b09 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:4)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/input.js new file mode 100644 index 0000000000..5f780ecff9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/input.js @@ -0,0 +1,2 @@ +interface A {} +interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/options.json new file mode 100644 index 0000000000..04242bd156 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:10)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/input.js new file mode 100644 index 0000000000..61596821e3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/input.js @@ -0,0 +1,2 @@ +let A = 1; +declare class A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/options.json new file mode 100644 index 0000000000..4a1b4e5c5c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:14)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/input.js new file mode 100644 index 0000000000..97428603f0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/input.js @@ -0,0 +1,2 @@ +let A = 1; +declare interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/options.json new file mode 100644 index 0000000000..187fea591b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:18)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/input.js new file mode 100644 index 0000000000..2e575bbc69 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/input.js @@ -0,0 +1,2 @@ +let A = 1; +interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/options.json new file mode 100644 index 0000000000..04242bd156 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:10)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/input.js new file mode 100644 index 0000000000..38b6005891 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/input.js @@ -0,0 +1,2 @@ +type A = number; +interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/options.json new file mode 100644 index 0000000000..04242bd156 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:10)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/input.js new file mode 100644 index 0000000000..c534e4739b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/input.js @@ -0,0 +1,2 @@ +var A = 1; +declare class A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/options.json new file mode 100644 index 0000000000..4a1b4e5c5c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:14)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/input.js new file mode 100644 index 0000000000..07a1fa47aa --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/input.js @@ -0,0 +1,2 @@ +var A = 1; +declare interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/options.json new file mode 100644 index 0000000000..187fea591b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:18)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/input.js new file mode 100644 index 0000000000..70f7e73cc0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/input.js @@ -0,0 +1,2 @@ +var A = 1; +interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/options.json new file mode 100644 index 0000000000..04242bd156 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:10)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/declare-module/input.js b/packages/babel-parser/test/fixtures/flow/scope/declare-module/input.js new file mode 100644 index 0000000000..3b25537ffc --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/declare-module/input.js @@ -0,0 +1,5 @@ +declare module A { + declare class X {} +} + +class X {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/declare-module/output.json b/packages/babel-parser/test/fixtures/flow/scope/declare-module/output.json new file mode 100644 index 0000000000..672f98d0ad --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/declare-module/output.json @@ -0,0 +1,190 @@ +{ + "type": "File", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareModule", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "A" + }, + "name": "A" + }, + "body": { + "type": "BlockStatement", + "start": 17, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "DeclareClass", + "start": 21, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "X" + }, + "name": "X" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 37, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ] + }, + "kind": "CommonJS" + }, + { + "type": "ClassDeclaration", + "start": 43, + "end": 53, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 49, + "end": 50, + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + }, + "identifierName": "X" + }, + "name": "X" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 51, + "end": 53, + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/input.js new file mode 100644 index 0000000000..22286388e0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/input.js @@ -0,0 +1,2 @@ +const A = 1; +opaque type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/options.json new file mode 100644 index 0000000000..81dc2c9079 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:12)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/input.js new file mode 100644 index 0000000000..09676cc695 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/input.js @@ -0,0 +1,2 @@ +const A = 1; +type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/options.json new file mode 100644 index 0000000000..1eed93f49a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:5)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/input.js new file mode 100644 index 0000000000..f388a626ba --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/input.js @@ -0,0 +1,2 @@ +let A = 1; +opaque type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/options.json new file mode 100644 index 0000000000..81dc2c9079 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:12)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/input.js new file mode 100644 index 0000000000..acd0aedaa6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/input.js @@ -0,0 +1,2 @@ +let A = 1; +type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/options.json new file mode 100644 index 0000000000..1eed93f49a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:5)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/input.js new file mode 100644 index 0000000000..68252d13d6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/input.js @@ -0,0 +1,2 @@ +opaque type A = {}; +const A = 1; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/options.json new file mode 100644 index 0000000000..336686170e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:6)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/input.js new file mode 100644 index 0000000000..cb701d75b8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/input.js @@ -0,0 +1,2 @@ +opaque type A = {}; +let A = 1; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/options.json new file mode 100644 index 0000000000..b6ff3a4b09 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:4)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/input.js new file mode 100644 index 0000000000..ea475eaf75 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/input.js @@ -0,0 +1,2 @@ +opaque type A = {}; +opaque type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/options.json new file mode 100644 index 0000000000..81dc2c9079 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:12)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/input.js new file mode 100644 index 0000000000..9f3827951e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/input.js @@ -0,0 +1,2 @@ +opaque type A = {}; +type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/options.json new file mode 100644 index 0000000000..1eed93f49a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:5)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/input.js new file mode 100644 index 0000000000..2652780119 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/input.js @@ -0,0 +1,2 @@ +opaque type A = {}; +var A = 1; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/options.json new file mode 100644 index 0000000000..b6ff3a4b09 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:4)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/input.js new file mode 100644 index 0000000000..2b045e915a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/input.js @@ -0,0 +1,2 @@ +type A = {}; +const A = 1; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/options.json new file mode 100644 index 0000000000..336686170e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:6)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/input.js new file mode 100644 index 0000000000..c827929c6d --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/input.js @@ -0,0 +1,2 @@ +type A = {}; +let A = 1; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/options.json new file mode 100644 index 0000000000..b6ff3a4b09 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:4)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/input.js new file mode 100644 index 0000000000..03d17d1612 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/input.js @@ -0,0 +1,2 @@ +type A = {}; +opaque type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/options.json new file mode 100644 index 0000000000..81dc2c9079 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:12)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/input.js new file mode 100644 index 0000000000..72146f4156 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/input.js @@ -0,0 +1,2 @@ +type A = {}; +type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/options.json new file mode 100644 index 0000000000..1eed93f49a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:5)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/input.js new file mode 100644 index 0000000000..04e932fa9c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/input.js @@ -0,0 +1,2 @@ +type A = {}; +var A = 1; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/options.json new file mode 100644 index 0000000000..b6ff3a4b09 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:4)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/input.js new file mode 100644 index 0000000000..e4d5ab41ec --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/input.js @@ -0,0 +1,2 @@ +var A = 1; +opaque type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/options.json new file mode 100644 index 0000000000..81dc2c9079 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:12)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/input.js new file mode 100644 index 0000000000..3427e135d6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/input.js @@ -0,0 +1,2 @@ +var A = 1; +type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/options.json new file mode 100644 index 0000000000..1eed93f49a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:5)" +} diff --git a/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/input.js b/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/input.js index f0afdd16f8..cd488659ac 100644 --- a/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/input.js +++ b/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/input.js @@ -1,2 +1,2 @@ export type Foo = number; -export opaque type Foo = number; +export opaque type Foo2 = number; diff --git a/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/output.json b/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/output.json index fc72d64676..70d30bbe8a 100644 --- a/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/output.json +++ b/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/output.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 58, + "end": 59, "loc": { "start": { "line": 1, @@ -9,13 +9,13 @@ }, "end": { "line": 2, - "column": 32 + "column": 33 } }, "program": { "type": "Program", "start": 0, - "end": 58, + "end": 59, "loc": { "start": { "line": 1, @@ -23,7 +23,7 @@ }, "end": { "line": 2, - "column": 32 + "column": 33 } }, "sourceType": "script", @@ -98,7 +98,7 @@ { "type": "ExportNamedDeclaration", "start": 26, - "end": 58, + "end": 59, "loc": { "start": { "line": 2, @@ -106,7 +106,7 @@ }, "end": { "line": 2, - "column": 32 + "column": 33 } }, "specifiers": [], @@ -115,7 +115,7 @@ "declaration": { "type": "OpaqueType", "start": 33, - "end": 58, + "end": 59, "loc": { "start": { "line": 2, @@ -123,13 +123,13 @@ }, "end": { "line": 2, - "column": 32 + "column": 33 } }, "id": { "type": "Identifier", "start": 45, - "end": 48, + "end": 49, "loc": { "start": { "line": 2, @@ -137,26 +137,26 @@ }, "end": { "line": 2, - "column": 22 + "column": 23 }, - "identifierName": "Foo" + "identifierName": "Foo2" }, - "name": "Foo" + "name": "Foo2" }, "typeParameters": null, "supertype": null, "impltype": { "type": "NumberTypeAnnotation", - "start": 51, - "end": 57, + "start": 52, + "end": 58, "loc": { "start": { "line": 2, - "column": 25 + "column": 26 }, "end": { "line": 2, - "column": 31 + "column": 32 } } } diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/input.js b/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/input.js index 777868f31e..04fd627b99 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/input.js +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/input.js @@ -1,16 +1,16 @@ // bounds -type T = any; -type T = mixed; -type T = empty; +type T1 = any; +type T2 = mixed; +type T3 = empty; // builtins -type T = void; -type T = number; -type T = string; -type T = bool; -type T = boolean; +type T4 = void; +type T5 = number; +type T6 = string; +type T7 = bool; +type T8 = boolean; // literal type annotations -type T = null; -type T = ""; -type T = 0; -type T = true; -type T = false; +type T9 = null; +type T10 = ""; +type T11 = 0; +type T12 = true; +type T13 = false; diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/output.json index 379ea71424..9b31791722 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/output.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 248, + "end": 265, "loc": { "start": { "line": 1, @@ -9,13 +9,13 @@ }, "end": { "line": 16, - "column": 15 + "column": 17 } }, "program": { "type": "Program", "start": 0, - "end": 248, + "end": 265, "loc": { "start": { "line": 1, @@ -23,7 +23,7 @@ }, "end": { "line": 16, - "column": 15 + "column": 17 } }, "sourceType": "module", @@ -32,7 +32,7 @@ { "type": "TypeAlias", "start": 10, - "end": 23, + "end": 24, "loc": { "start": { "line": 2, @@ -40,13 +40,13 @@ }, "end": { "line": 2, - "column": 13 + "column": 14 } }, "id": { "type": "Identifier", "start": 15, - "end": 16, + "end": 17, "loc": { "start": { "line": 2, @@ -54,25 +54,25 @@ }, "end": { "line": 2, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T1" }, - "name": "T" + "name": "T1" }, "typeParameters": null, "right": { "type": "AnyTypeAnnotation", - "start": 19, - "end": 22, + "start": 20, + "end": 23, "loc": { "start": { "line": 2, - "column": 9 + "column": 10 }, "end": { "line": 2, - "column": 12 + "column": 13 } } }, @@ -97,8 +97,8 @@ }, { "type": "TypeAlias", - "start": 24, - "end": 39, + "start": 25, + "end": 41, "loc": { "start": { "line": 3, @@ -106,13 +106,13 @@ }, "end": { "line": 3, - "column": 15 + "column": 16 } }, "id": { "type": "Identifier", - "start": 29, - "end": 30, + "start": 30, + "end": 32, "loc": { "start": { "line": 3, @@ -120,33 +120,33 @@ }, "end": { "line": 3, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T2" }, - "name": "T" + "name": "T2" }, "typeParameters": null, "right": { "type": "MixedTypeAnnotation", - "start": 33, - "end": 38, + "start": 35, + "end": 40, "loc": { "start": { "line": 3, - "column": 9 + "column": 10 }, "end": { "line": 3, - "column": 14 + "column": 15 } } } }, { "type": "TypeAlias", - "start": 40, - "end": 55, + "start": 42, + "end": 58, "loc": { "start": { "line": 4, @@ -154,13 +154,13 @@ }, "end": { "line": 4, - "column": 15 + "column": 16 } }, "id": { "type": "Identifier", - "start": 45, - "end": 46, + "start": 47, + "end": 49, "loc": { "start": { "line": 4, @@ -168,25 +168,25 @@ }, "end": { "line": 4, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T3" }, - "name": "T" + "name": "T3" }, "typeParameters": null, "right": { "type": "EmptyTypeAnnotation", - "start": 49, - "end": 54, + "start": 52, + "end": 57, "loc": { "start": { "line": 4, - "column": 9 + "column": 10 }, "end": { "line": 4, - "column": 14 + "column": 15 } } }, @@ -194,8 +194,8 @@ { "type": "CommentLine", "value": " builtins", - "start": 56, - "end": 67, + "start": 59, + "end": 70, "loc": { "start": { "line": 5, @@ -211,8 +211,8 @@ }, { "type": "TypeAlias", - "start": 68, - "end": 82, + "start": 71, + "end": 86, "loc": { "start": { "line": 6, @@ -220,13 +220,13 @@ }, "end": { "line": 6, - "column": 14 + "column": 15 } }, "id": { "type": "Identifier", - "start": 73, - "end": 74, + "start": 76, + "end": 78, "loc": { "start": { "line": 6, @@ -234,25 +234,25 @@ }, "end": { "line": 6, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T4" }, - "name": "T" + "name": "T4" }, "typeParameters": null, "right": { "type": "VoidTypeAnnotation", - "start": 77, - "end": 81, + "start": 81, + "end": 85, "loc": { "start": { "line": 6, - "column": 9 + "column": 10 }, "end": { "line": 6, - "column": 13 + "column": 14 } } }, @@ -260,8 +260,8 @@ { "type": "CommentLine", "value": " builtins", - "start": 56, - "end": 67, + "start": 59, + "end": 70, "loc": { "start": { "line": 5, @@ -277,8 +277,8 @@ }, { "type": "TypeAlias", - "start": 83, - "end": 99, + "start": 87, + "end": 104, "loc": { "start": { "line": 7, @@ -286,157 +286,157 @@ }, "end": { "line": 7, - "column": 16 - } - }, - "id": { - "type": "Identifier", - "start": 88, - "end": 89, - "loc": { - "start": { - "line": 7, - "column": 5 - }, - "end": { - "line": 7, - "column": 6 - }, - "identifierName": "T" - }, - "name": "T" - }, - "typeParameters": null, - "right": { - "type": "NumberTypeAnnotation", - "start": 92, - "end": 98, - "loc": { - "start": { - "line": 7, - "column": 9 - }, - "end": { - "line": 7, - "column": 15 - } - } - } - }, - { - "type": "TypeAlias", - "start": 100, - "end": 116, - "loc": { - "start": { - "line": 8, - "column": 0 - }, - "end": { - "line": 8, - "column": 16 - } - }, - "id": { - "type": "Identifier", - "start": 105, - "end": 106, - "loc": { - "start": { - "line": 8, - "column": 5 - }, - "end": { - "line": 8, - "column": 6 - }, - "identifierName": "T" - }, - "name": "T" - }, - "typeParameters": null, - "right": { - "type": "StringTypeAnnotation", - "start": 109, - "end": 115, - "loc": { - "start": { - "line": 8, - "column": 9 - }, - "end": { - "line": 8, - "column": 15 - } - } - } - }, - { - "type": "TypeAlias", - "start": 117, - "end": 131, - "loc": { - "start": { - "line": 9, - "column": 0 - }, - "end": { - "line": 9, - "column": 14 - } - }, - "id": { - "type": "Identifier", - "start": 122, - "end": 123, - "loc": { - "start": { - "line": 9, - "column": 5 - }, - "end": { - "line": 9, - "column": 6 - }, - "identifierName": "T" - }, - "name": "T" - }, - "typeParameters": null, - "right": { - "type": "BooleanTypeAnnotation", - "start": 126, - "end": 130, - "loc": { - "start": { - "line": 9, - "column": 9 - }, - "end": { - "line": 9, - "column": 13 - } - } - } - }, - { - "type": "TypeAlias", - "start": 132, - "end": 149, - "loc": { - "start": { - "line": 10, - "column": 0 - }, - "end": { - "line": 10, "column": 17 } }, "id": { "type": "Identifier", - "start": 137, - "end": 138, + "start": 92, + "end": 94, + "loc": { + "start": { + "line": 7, + "column": 5 + }, + "end": { + "line": 7, + "column": 7 + }, + "identifierName": "T5" + }, + "name": "T5" + }, + "typeParameters": null, + "right": { + "type": "NumberTypeAnnotation", + "start": 97, + "end": 103, + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 16 + } + } + } + }, + { + "type": "TypeAlias", + "start": 105, + "end": 122, + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 110, + "end": 112, + "loc": { + "start": { + "line": 8, + "column": 5 + }, + "end": { + "line": 8, + "column": 7 + }, + "identifierName": "T6" + }, + "name": "T6" + }, + "typeParameters": null, + "right": { + "type": "StringTypeAnnotation", + "start": 115, + "end": 121, + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 16 + } + } + } + }, + { + "type": "TypeAlias", + "start": 123, + "end": 138, + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 15 + } + }, + "id": { + "type": "Identifier", + "start": 128, + "end": 130, + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 7 + }, + "identifierName": "T7" + }, + "name": "T7" + }, + "typeParameters": null, + "right": { + "type": "BooleanTypeAnnotation", + "start": 133, + "end": 137, + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 14 + } + } + } + }, + { + "type": "TypeAlias", + "start": 139, + "end": 157, + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 144, + "end": 146, "loc": { "start": { "line": 10, @@ -444,25 +444,25 @@ }, "end": { "line": 10, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T8" }, - "name": "T" + "name": "T8" }, "typeParameters": null, "right": { "type": "BooleanTypeAnnotation", - "start": 141, - "end": 148, + "start": 149, + "end": 156, "loc": { "start": { "line": 10, - "column": 9 + "column": 10 }, "end": { "line": 10, - "column": 16 + "column": 17 } } }, @@ -470,8 +470,8 @@ { "type": "CommentLine", "value": " literal type annotations", - "start": 150, - "end": 177, + "start": 158, + "end": 185, "loc": { "start": { "line": 11, @@ -487,8 +487,8 @@ }, { "type": "TypeAlias", - "start": 178, - "end": 192, + "start": 186, + "end": 201, "loc": { "start": { "line": 12, @@ -496,13 +496,13 @@ }, "end": { "line": 12, - "column": 14 + "column": 15 } }, "id": { "type": "Identifier", - "start": 183, - "end": 184, + "start": 191, + "end": 193, "loc": { "start": { "line": 12, @@ -510,25 +510,25 @@ }, "end": { "line": 12, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T9" }, - "name": "T" + "name": "T9" }, "typeParameters": null, "right": { "type": "NullLiteralTypeAnnotation", - "start": 187, - "end": 191, + "start": 196, + "end": 200, "loc": { "start": { "line": 12, - "column": 9 + "column": 10 }, "end": { "line": 12, - "column": 13 + "column": 14 } } }, @@ -536,8 +536,8 @@ { "type": "CommentLine", "value": " literal type annotations", - "start": 150, - "end": 177, + "start": 158, + "end": 185, "loc": { "start": { "line": 11, @@ -553,8 +553,8 @@ }, { "type": "TypeAlias", - "start": 193, - "end": 205, + "start": 202, + "end": 216, "loc": { "start": { "line": 13, @@ -562,13 +562,13 @@ }, "end": { "line": 13, - "column": 12 + "column": 14 } }, "id": { "type": "Identifier", - "start": 198, - "end": 199, + "start": 207, + "end": 210, "loc": { "start": { "line": 13, @@ -576,25 +576,25 @@ }, "end": { "line": 13, - "column": 6 + "column": 8 }, - "identifierName": "T" + "identifierName": "T10" }, - "name": "T" + "name": "T10" }, "typeParameters": null, "right": { "type": "StringLiteralTypeAnnotation", - "start": 202, - "end": 204, + "start": 213, + "end": 215, "loc": { "start": { "line": 13, - "column": 9 + "column": 11 }, "end": { "line": 13, - "column": 11 + "column": 13 } }, "extra": { @@ -606,8 +606,8 @@ }, { "type": "TypeAlias", - "start": 206, - "end": 217, + "start": 217, + "end": 230, "loc": { "start": { "line": 14, @@ -615,13 +615,13 @@ }, "end": { "line": 14, - "column": 11 + "column": 13 } }, "id": { "type": "Identifier", - "start": 211, - "end": 212, + "start": 222, + "end": 225, "loc": { "start": { "line": 14, @@ -629,25 +629,25 @@ }, "end": { "line": 14, - "column": 6 + "column": 8 }, - "identifierName": "T" + "identifierName": "T11" }, - "name": "T" + "name": "T11" }, "typeParameters": null, "right": { "type": "NumberLiteralTypeAnnotation", - "start": 215, - "end": 216, + "start": 228, + "end": 229, "loc": { "start": { "line": 14, - "column": 9 + "column": 11 }, "end": { "line": 14, - "column": 10 + "column": 12 } }, "extra": { @@ -659,8 +659,8 @@ }, { "type": "TypeAlias", - "start": 218, - "end": 232, + "start": 231, + "end": 247, "loc": { "start": { "line": 15, @@ -668,13 +668,13 @@ }, "end": { "line": 15, - "column": 14 + "column": 16 } }, "id": { "type": "Identifier", - "start": 223, - "end": 224, + "start": 236, + "end": 239, "loc": { "start": { "line": 15, @@ -682,25 +682,25 @@ }, "end": { "line": 15, - "column": 6 + "column": 8 }, - "identifierName": "T" + "identifierName": "T12" }, - "name": "T" + "name": "T12" }, "typeParameters": null, "right": { "type": "BooleanLiteralTypeAnnotation", - "start": 227, - "end": 231, + "start": 242, + "end": 246, "loc": { "start": { "line": 15, - "column": 9 + "column": 11 }, "end": { "line": 15, - "column": 13 + "column": 15 } }, "value": true @@ -708,8 +708,8 @@ }, { "type": "TypeAlias", - "start": 233, - "end": 248, + "start": 248, + "end": 265, "loc": { "start": { "line": 16, @@ -717,13 +717,13 @@ }, "end": { "line": 16, - "column": 15 + "column": 17 } }, "id": { "type": "Identifier", - "start": 238, - "end": 239, + "start": 253, + "end": 256, "loc": { "start": { "line": 16, @@ -731,25 +731,25 @@ }, "end": { "line": 16, - "column": 6 + "column": 8 }, - "identifierName": "T" + "identifierName": "T13" }, - "name": "T" + "name": "T13" }, "typeParameters": null, "right": { "type": "BooleanLiteralTypeAnnotation", - "start": 242, - "end": 247, + "start": 259, + "end": 264, "loc": { "start": { "line": 16, - "column": 9 + "column": 11 }, "end": { "line": 16, - "column": 14 + "column": 16 } }, "value": false @@ -778,8 +778,8 @@ { "type": "CommentLine", "value": " builtins", - "start": 56, - "end": 67, + "start": 59, + "end": 70, "loc": { "start": { "line": 5, @@ -794,8 +794,8 @@ { "type": "CommentLine", "value": " literal type annotations", - "start": 150, - "end": 177, + "start": 158, + "end": 185, "loc": { "start": { "line": 11, diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/input.js b/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/input.js index 216a4222b3..435219343e 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/input.js +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/input.js @@ -1,12 +1,12 @@ type T = { a: () => void }; -type T = { a: () => void }; -type T = { a(): void }; -type T = { a(): void }; +type T1 = { a: () => void }; +type T2 = { a(): void }; +type T3 = { a(): void }; -type T = { (): number }; -type T = { (x: T): number; } +type T4 = { (): number }; +type T5 = { (x: T): number; } -declare class T { foo(): number; } -declare class T { static foo(): number; } -declare class T { (): number } -declare class T { static (): number } +declare class T6 { foo(): number; } +declare class T7 { static foo(): number; } +declare class T8 { (): number } +declare class T9 { static (): number } diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/output.json index f72e8ff175..49fb1b3a7b 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/output.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 314, + "end": 323, "loc": { "start": { "line": 1, @@ -9,13 +9,13 @@ }, "end": { "line": 12, - "column": 37 + "column": 38 } }, "program": { "type": "Program", "start": 0, - "end": 314, + "end": 323, "loc": { "start": { "line": 1, @@ -23,7 +23,7 @@ }, "end": { "line": 12, - "column": 37 + "column": 38 } }, "sourceType": "module", @@ -158,7 +158,7 @@ { "type": "TypeAlias", "start": 28, - "end": 58, + "end": 59, "loc": { "start": { "line": 2, @@ -166,13 +166,13 @@ }, "end": { "line": 2, - "column": 30 + "column": 31 } }, "id": { "type": "Identifier", "start": 33, - "end": 34, + "end": 35, "loc": { "start": { "line": 2, @@ -180,55 +180,55 @@ }, "end": { "line": 2, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T1" }, - "name": "T" + "name": "T1" }, "typeParameters": null, "right": { "type": "ObjectTypeAnnotation", - "start": 37, - "end": 57, + "start": 38, + "end": 58, "loc": { "start": { "line": 2, - "column": 9 + "column": 10 }, "end": { "line": 2, - "column": 29 + "column": 30 } }, "callProperties": [], "properties": [ { "type": "ObjectTypeProperty", - "start": 39, - "end": 55, + "start": 40, + "end": 56, "loc": { "start": { "line": 2, - "column": 11 + "column": 12 }, "end": { "line": 2, - "column": 27 + "column": 28 } }, "key": { "type": "Identifier", - "start": 39, - "end": 40, + "start": 40, + "end": 41, "loc": { "start": { "line": 2, - "column": 11 + "column": 12 }, "end": { "line": 2, - "column": 12 + "column": 13 }, "identifierName": "a" }, @@ -240,45 +240,45 @@ "method": false, "value": { "type": "FunctionTypeAnnotation", - "start": 42, - "end": 55, + "start": 43, + "end": 56, "loc": { "start": { "line": 2, - "column": 14 + "column": 15 }, "end": { "line": 2, - "column": 27 + "column": 28 } }, "typeParameters": { "type": "TypeParameterDeclaration", - "start": 42, - "end": 45, + "start": 43, + "end": 46, "loc": { "start": { "line": 2, - "column": 14 + "column": 15 }, "end": { "line": 2, - "column": 17 + "column": 18 } }, "params": [ { "type": "TypeParameter", - "start": 43, - "end": 44, + "start": 44, + "end": 45, "loc": { "start": { "line": 2, - "column": 15 + "column": 16 }, "end": { "line": 2, - "column": 16 + "column": 17 } }, "name": "T", @@ -290,16 +290,16 @@ "rest": null, "returnType": { "type": "VoidTypeAnnotation", - "start": 51, - "end": 55, + "start": 52, + "end": 56, "loc": { "start": { "line": 2, - "column": 23 + "column": 24 }, "end": { "line": 2, - "column": 27 + "column": 28 } } } @@ -316,8 +316,8 @@ }, { "type": "TypeAlias", - "start": 59, - "end": 82, + "start": 60, + "end": 84, "loc": { "start": { "line": 3, @@ -325,13 +325,13 @@ }, "end": { "line": 3, - "column": 23 + "column": 24 } }, "id": { "type": "Identifier", - "start": 64, - "end": 65, + "start": 65, + "end": 67, "loc": { "start": { "line": 3, @@ -339,55 +339,55 @@ }, "end": { "line": 3, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T2" }, - "name": "T" + "name": "T2" }, "typeParameters": null, "right": { "type": "ObjectTypeAnnotation", - "start": 68, - "end": 81, + "start": 70, + "end": 83, "loc": { "start": { "line": 3, - "column": 9 + "column": 10 }, "end": { "line": 3, - "column": 22 + "column": 23 } }, "callProperties": [], "properties": [ { "type": "ObjectTypeProperty", - "start": 70, - "end": 79, + "start": 72, + "end": 81, "loc": { "start": { "line": 3, - "column": 11 + "column": 12 }, "end": { "line": 3, - "column": 20 + "column": 21 } }, "key": { "type": "Identifier", - "start": 70, - "end": 71, + "start": 72, + "end": 73, "loc": { "start": { "line": 3, - "column": 11 + "column": 12 }, "end": { "line": 3, - "column": 12 + "column": 13 }, "identifierName": "a" }, @@ -399,16 +399,16 @@ "method": true, "value": { "type": "FunctionTypeAnnotation", - "start": 70, - "end": 79, + "start": 72, + "end": 81, "loc": { "start": { "line": 3, - "column": 11 + "column": 12 }, "end": { "line": 3, - "column": 20 + "column": 21 } }, "params": [], @@ -416,16 +416,16 @@ "typeParameters": null, "returnType": { "type": "VoidTypeAnnotation", - "start": 75, - "end": 79, + "start": 77, + "end": 81, "loc": { "start": { "line": 3, - "column": 16 + "column": 17 }, "end": { "line": 3, - "column": 20 + "column": 21 } } } @@ -441,8 +441,8 @@ }, { "type": "TypeAlias", - "start": 83, - "end": 109, + "start": 85, + "end": 112, "loc": { "start": { "line": 4, @@ -450,13 +450,13 @@ }, "end": { "line": 4, - "column": 26 + "column": 27 } }, "id": { "type": "Identifier", - "start": 88, - "end": 89, + "start": 90, + "end": 92, "loc": { "start": { "line": 4, @@ -464,55 +464,55 @@ }, "end": { "line": 4, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T3" }, - "name": "T" + "name": "T3" }, "typeParameters": null, "right": { "type": "ObjectTypeAnnotation", - "start": 92, - "end": 108, + "start": 95, + "end": 111, "loc": { "start": { "line": 4, - "column": 9 + "column": 10 }, "end": { "line": 4, - "column": 25 + "column": 26 } }, "callProperties": [], "properties": [ { "type": "ObjectTypeProperty", - "start": 94, - "end": 106, + "start": 97, + "end": 109, "loc": { "start": { "line": 4, - "column": 11 + "column": 12 }, "end": { "line": 4, - "column": 23 + "column": 24 } }, "key": { "type": "Identifier", - "start": 94, - "end": 95, + "start": 97, + "end": 98, "loc": { "start": { "line": 4, - "column": 11 + "column": 12 }, "end": { "line": 4, - "column": 12 + "column": 13 }, "identifierName": "a" }, @@ -524,47 +524,47 @@ "method": true, "value": { "type": "FunctionTypeAnnotation", - "start": 94, - "end": 106, + "start": 97, + "end": 109, "loc": { "start": { "line": 4, - "column": 11 + "column": 12 }, "end": { "line": 4, - "column": 23 + "column": 24 } }, "params": [], "rest": null, "typeParameters": { "type": "TypeParameterDeclaration", - "start": 95, - "end": 98, + "start": 98, + "end": 101, "loc": { "start": { "line": 4, - "column": 12 + "column": 13 }, "end": { "line": 4, - "column": 15 + "column": 16 } }, "params": [ { "type": "TypeParameter", - "start": 96, - "end": 97, + "start": 99, + "end": 100, "loc": { "start": { "line": 4, - "column": 13 + "column": 14 }, "end": { "line": 4, - "column": 14 + "column": 15 } }, "name": "T", @@ -574,16 +574,16 @@ }, "returnType": { "type": "VoidTypeAnnotation", - "start": 102, - "end": 106, + "start": 105, + "end": 109, "loc": { "start": { "line": 4, - "column": 19 + "column": 20 }, "end": { "line": 4, - "column": 23 + "column": 24 } } } @@ -599,8 +599,8 @@ }, { "type": "TypeAlias", - "start": 111, - "end": 135, + "start": 114, + "end": 139, "loc": { "start": { "line": 6, @@ -608,13 +608,13 @@ }, "end": { "line": 6, - "column": 24 + "column": 25 } }, "id": { "type": "Identifier", - "start": 116, - "end": 117, + "start": 119, + "end": 121, "loc": { "start": { "line": 6, @@ -622,55 +622,55 @@ }, "end": { "line": 6, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T4" }, - "name": "T" + "name": "T4" }, "typeParameters": null, "right": { "type": "ObjectTypeAnnotation", - "start": 120, - "end": 134, + "start": 124, + "end": 138, "loc": { "start": { "line": 6, - "column": 9 + "column": 10 }, "end": { "line": 6, - "column": 23 + "column": 24 } }, "callProperties": [ { "type": "ObjectTypeCallProperty", - "start": 122, - "end": 132, + "start": 126, + "end": 136, "loc": { "start": { "line": 6, - "column": 11 + "column": 12 }, "end": { "line": 6, - "column": 21 + "column": 22 } }, "static": false, "value": { "type": "FunctionTypeAnnotation", - "start": 122, - "end": 132, + "start": 126, + "end": 136, "loc": { "start": { "line": 6, - "column": 11 + "column": 12 }, "end": { "line": 6, - "column": 21 + "column": 22 } }, "params": [], @@ -678,16 +678,16 @@ "typeParameters": null, "returnType": { "type": "NumberTypeAnnotation", - "start": 126, - "end": 132, + "start": 130, + "end": 136, "loc": { "start": { "line": 6, - "column": 15 + "column": 16 }, "end": { "line": 6, - "column": 21 + "column": 22 } } } @@ -703,8 +703,8 @@ }, { "type": "TypeAlias", - "start": 136, - "end": 167, + "start": 140, + "end": 172, "loc": { "start": { "line": 7, @@ -712,13 +712,13 @@ }, "end": { "line": 7, - "column": 31 + "column": 32 } }, "id": { "type": "Identifier", - "start": 141, - "end": 142, + "start": 145, + "end": 147, "loc": { "start": { "line": 7, @@ -726,84 +726,84 @@ }, "end": { "line": 7, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T5" }, - "name": "T" + "name": "T5" }, "typeParameters": null, "right": { "type": "ObjectTypeAnnotation", - "start": 145, - "end": 167, + "start": 150, + "end": 172, "loc": { "start": { "line": 7, - "column": 9 + "column": 10 }, "end": { "line": 7, - "column": 31 + "column": 32 } }, "callProperties": [ { "type": "ObjectTypeCallProperty", - "start": 147, - "end": 164, + "start": 152, + "end": 169, "loc": { "start": { "line": 7, - "column": 11 + "column": 12 }, "end": { "line": 7, - "column": 28 + "column": 29 } }, "static": false, "value": { "type": "FunctionTypeAnnotation", - "start": 147, - "end": 164, + "start": 152, + "end": 169, "loc": { "start": { "line": 7, - "column": 11 + "column": 12 }, "end": { "line": 7, - "column": 28 + "column": 29 } }, "params": [ { "type": "FunctionTypeParam", - "start": 151, - "end": 155, + "start": 156, + "end": 160, "loc": { "start": { "line": 7, - "column": 15 + "column": 16 }, "end": { "line": 7, - "column": 19 + "column": 20 } }, "name": { "type": "Identifier", - "start": 151, - "end": 152, + "start": 156, + "end": 157, "loc": { "start": { "line": 7, - "column": 15 + "column": 16 }, "end": { "line": 7, - "column": 16 + "column": 17 }, "identifierName": "x" }, @@ -812,31 +812,31 @@ "optional": false, "typeAnnotation": { "type": "GenericTypeAnnotation", - "start": 154, - "end": 155, + "start": 159, + "end": 160, "loc": { "start": { "line": 7, - "column": 18 + "column": 19 }, "end": { "line": 7, - "column": 19 + "column": 20 } }, "typeParameters": null, "id": { "type": "Identifier", - "start": 154, - "end": 155, + "start": 159, + "end": 160, "loc": { "start": { "line": 7, - "column": 18 + "column": 19 }, "end": { "line": 7, - "column": 19 + "column": 20 }, "identifierName": "T" }, @@ -848,31 +848,31 @@ "rest": null, "typeParameters": { "type": "TypeParameterDeclaration", - "start": 147, - "end": 150, + "start": 152, + "end": 155, "loc": { "start": { "line": 7, - "column": 11 + "column": 12 }, "end": { "line": 7, - "column": 14 + "column": 15 } }, "params": [ { "type": "TypeParameter", - "start": 148, - "end": 149, + "start": 153, + "end": 154, "loc": { "start": { "line": 7, - "column": 12 + "column": 13 }, "end": { "line": 7, - "column": 13 + "column": 14 } }, "name": "T", @@ -882,16 +882,16 @@ }, "returnType": { "type": "NumberTypeAnnotation", - "start": 158, - "end": 164, + "start": 163, + "end": 169, "loc": { "start": { "line": 7, - "column": 22 + "column": 23 }, "end": { "line": 7, - "column": 28 + "column": 29 } } } @@ -907,8 +907,8 @@ }, { "type": "DeclareClass", - "start": 169, - "end": 203, + "start": 174, + "end": 209, "loc": { "start": { "line": 9, @@ -916,13 +916,13 @@ }, "end": { "line": 9, - "column": 34 + "column": 35 } }, "id": { "type": "Identifier", - "start": 183, - "end": 184, + "start": 188, + "end": 190, "loc": { "start": { "line": 9, @@ -930,11 +930,11 @@ }, "end": { "line": 9, - "column": 15 + "column": 16 }, - "identifierName": "T" + "identifierName": "T6" }, - "name": "T" + "name": "T6" }, "typeParameters": null, "extends": [], @@ -942,46 +942,46 @@ "mixins": [], "body": { "type": "ObjectTypeAnnotation", - "start": 185, - "end": 203, + "start": 191, + "end": 209, "loc": { "start": { "line": 9, - "column": 16 + "column": 17 }, "end": { "line": 9, - "column": 34 + "column": 35 } }, "callProperties": [], "properties": [ { "type": "ObjectTypeProperty", - "start": 187, - "end": 200, + "start": 193, + "end": 206, "loc": { "start": { "line": 9, - "column": 18 + "column": 19 }, "end": { "line": 9, - "column": 31 + "column": 32 } }, "key": { "type": "Identifier", - "start": 187, - "end": 190, + "start": 193, + "end": 196, "loc": { "start": { "line": 9, - "column": 18 + "column": 19 }, "end": { "line": 9, - "column": 21 + "column": 22 }, "identifierName": "foo" }, @@ -993,16 +993,16 @@ "method": true, "value": { "type": "FunctionTypeAnnotation", - "start": 187, - "end": 200, + "start": 193, + "end": 206, "loc": { "start": { "line": 9, - "column": 18 + "column": 19 }, "end": { "line": 9, - "column": 31 + "column": 32 } }, "params": [], @@ -1010,16 +1010,16 @@ "typeParameters": null, "returnType": { "type": "NumberTypeAnnotation", - "start": 194, - "end": 200, + "start": 200, + "end": 206, "loc": { "start": { "line": 9, - "column": 25 + "column": 26 }, "end": { "line": 9, - "column": 31 + "column": 32 } } } @@ -1034,8 +1034,8 @@ }, { "type": "DeclareClass", - "start": 204, - "end": 245, + "start": 210, + "end": 252, "loc": { "start": { "line": 10, @@ -1043,13 +1043,13 @@ }, "end": { "line": 10, - "column": 41 + "column": 42 } }, "id": { "type": "Identifier", - "start": 218, - "end": 219, + "start": 224, + "end": 226, "loc": { "start": { "line": 10, @@ -1057,11 +1057,11 @@ }, "end": { "line": 10, - "column": 15 + "column": 16 }, - "identifierName": "T" + "identifierName": "T7" }, - "name": "T" + "name": "T7" }, "typeParameters": null, "extends": [], @@ -1069,46 +1069,46 @@ "mixins": [], "body": { "type": "ObjectTypeAnnotation", - "start": 220, - "end": 245, + "start": 227, + "end": 252, "loc": { "start": { "line": 10, - "column": 16 + "column": 17 }, "end": { "line": 10, - "column": 41 + "column": 42 } }, "callProperties": [], "properties": [ { "type": "ObjectTypeProperty", - "start": 222, - "end": 242, + "start": 229, + "end": 249, "loc": { "start": { "line": 10, - "column": 18 + "column": 19 }, "end": { "line": 10, - "column": 38 + "column": 39 } }, "key": { "type": "Identifier", - "start": 229, - "end": 232, + "start": 236, + "end": 239, "loc": { "start": { "line": 10, - "column": 25 + "column": 26 }, "end": { "line": 10, - "column": 28 + "column": 29 }, "identifierName": "foo" }, @@ -1120,16 +1120,16 @@ "method": true, "value": { "type": "FunctionTypeAnnotation", - "start": 222, - "end": 242, + "start": 229, + "end": 249, "loc": { "start": { "line": 10, - "column": 18 + "column": 19 }, "end": { "line": 10, - "column": 38 + "column": 39 } }, "params": [], @@ -1137,16 +1137,16 @@ "typeParameters": null, "returnType": { "type": "NumberTypeAnnotation", - "start": 236, - "end": 242, + "start": 243, + "end": 249, "loc": { "start": { "line": 10, - "column": 32 + "column": 33 }, "end": { "line": 10, - "column": 38 + "column": 39 } } } @@ -1161,8 +1161,8 @@ }, { "type": "DeclareClass", - "start": 246, - "end": 276, + "start": 253, + "end": 284, "loc": { "start": { "line": 11, @@ -1170,13 +1170,13 @@ }, "end": { "line": 11, - "column": 30 + "column": 31 } }, "id": { "type": "Identifier", - "start": 260, - "end": 261, + "start": 267, + "end": 269, "loc": { "start": { "line": 11, @@ -1184,11 +1184,11 @@ }, "end": { "line": 11, - "column": 15 + "column": 16 }, - "identifierName": "T" + "identifierName": "T8" }, - "name": "T" + "name": "T8" }, "typeParameters": null, "extends": [], @@ -1196,46 +1196,46 @@ "mixins": [], "body": { "type": "ObjectTypeAnnotation", - "start": 262, - "end": 276, + "start": 270, + "end": 284, "loc": { "start": { "line": 11, - "column": 16 + "column": 17 }, "end": { "line": 11, - "column": 30 + "column": 31 } }, "callProperties": [ { "type": "ObjectTypeCallProperty", - "start": 264, - "end": 274, + "start": 272, + "end": 282, "loc": { "start": { "line": 11, - "column": 18 + "column": 19 }, "end": { "line": 11, - "column": 28 + "column": 29 } }, "static": false, "value": { "type": "FunctionTypeAnnotation", - "start": 264, - "end": 274, + "start": 272, + "end": 282, "loc": { "start": { "line": 11, - "column": 18 + "column": 19 }, "end": { "line": 11, - "column": 28 + "column": 29 } }, "params": [], @@ -1243,16 +1243,16 @@ "typeParameters": null, "returnType": { "type": "NumberTypeAnnotation", - "start": 268, - "end": 274, + "start": 276, + "end": 282, "loc": { "start": { "line": 11, - "column": 22 + "column": 23 }, "end": { "line": 11, - "column": 28 + "column": 29 } } } @@ -1267,8 +1267,8 @@ }, { "type": "DeclareClass", - "start": 277, - "end": 314, + "start": 285, + "end": 323, "loc": { "start": { "line": 12, @@ -1276,13 +1276,13 @@ }, "end": { "line": 12, - "column": 37 + "column": 38 } }, "id": { "type": "Identifier", - "start": 291, - "end": 292, + "start": 299, + "end": 301, "loc": { "start": { "line": 12, @@ -1290,11 +1290,11 @@ }, "end": { "line": 12, - "column": 15 + "column": 16 }, - "identifierName": "T" + "identifierName": "T9" }, - "name": "T" + "name": "T9" }, "typeParameters": null, "extends": [], @@ -1302,46 +1302,46 @@ "mixins": [], "body": { "type": "ObjectTypeAnnotation", - "start": 293, - "end": 314, + "start": 302, + "end": 323, "loc": { "start": { "line": 12, - "column": 16 + "column": 17 }, "end": { "line": 12, - "column": 37 + "column": 38 } }, "callProperties": [ { "type": "ObjectTypeCallProperty", - "start": 295, - "end": 312, + "start": 304, + "end": 321, "loc": { "start": { "line": 12, - "column": 18 + "column": 19 }, "end": { "line": 12, - "column": 35 + "column": 36 } }, "static": true, "value": { "type": "FunctionTypeAnnotation", - "start": 302, - "end": 312, + "start": 311, + "end": 321, "loc": { "start": { "line": 12, - "column": 25 + "column": 26 }, "end": { "line": 12, - "column": 35 + "column": 36 } }, "params": [], @@ -1349,16 +1349,16 @@ "typeParameters": null, "returnType": { "type": "NumberTypeAnnotation", - "start": 306, - "end": 312, + "start": 315, + "end": 321, "loc": { "start": { "line": 12, - "column": 29 + "column": 30 }, "end": { "line": 12, - "column": 35 + "column": 36 } } } diff --git a/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/input.js b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/input.js new file mode 100644 index 0000000000..62acca05ef --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/input.js @@ -0,0 +1,2 @@ +const X = ""; +type X = number; diff --git a/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/output.json b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/output.json new file mode 100644 index 0000000000..b51eb30f5c --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "X" + }, + "name": "X" + }, + "init": { + "type": "StringLiteral", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "extra": { + "rawValue": "", + "raw": "\"\"" + }, + "value": "" + } + } + ], + "kind": "const" + }, + { + "type": "TSTypeAliasDeclaration", + "start": 14, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "X" + }, + "name": "X" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 23, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/input.js b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/input.js new file mode 100644 index 0000000000..fe2809ad6b --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/input.js @@ -0,0 +1,2 @@ +let X = ""; +type X = number; diff --git a/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/output.json b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/output.json new file mode 100644 index 0000000000..8c157d8a36 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "X" + }, + "name": "X" + }, + "init": { + "type": "StringLiteral", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": "", + "raw": "\"\"" + }, + "value": "" + } + } + ], + "kind": "let" + }, + { + "type": "TSTypeAliasDeclaration", + "start": 12, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "X" + }, + "name": "X" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/input.js b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/input.js new file mode 100644 index 0000000000..856d8ef6f3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/input.js @@ -0,0 +1,2 @@ +var X = ""; +type X = number; diff --git a/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/output.json b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/output.json new file mode 100644 index 0000000000..6cfc11c093 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "X" + }, + "name": "X" + }, + "init": { + "type": "StringLiteral", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": "", + "raw": "\"\"" + }, + "value": "" + } + } + ], + "kind": "var" + }, + { + "type": "TSTypeAliasDeclaration", + "start": 12, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "X" + }, + "name": "X" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-plugin-transform-classes/src/transformClass.js b/packages/babel-plugin-transform-classes/src/transformClass.js index b537c00b3a..0335e36343 100644 --- a/packages/babel-plugin-transform-classes/src/transformClass.js +++ b/packages/babel-plugin-transform-classes/src/transformClass.js @@ -19,22 +19,6 @@ function buildConstructor(classRef, constructorBody, node) { return func; } -const verifyConstructorVisitor = traverse.visitors.merge([ - environmentVisitor, - { - Super(path, state) { - if (state.isDerived) return; - - const { node, parentPath } = path; - if (parentPath.isCallExpression({ callee: node })) { - throw path.buildCodeFrameError( - "super() is only allowed in a derived constructor", - ); - } - }, - }, -]); - export default function transformClass( path: NodePath, file: any, @@ -180,13 +164,6 @@ export default function transformClass( if (t.isClassMethod(node)) { const isConstructor = node.kind === "constructor"; - if (isConstructor) { - path.traverse(verifyConstructorVisitor, { - isDerived: classState.isDerived, - file: classState.file, - }); - } - const replaceSupers = new ReplaceSupers({ methodPath: path, objectRef: classState.classRef, diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/input.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/input.js deleted file mode 100644 index 036ce36e39..0000000000 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/input.js +++ /dev/null @@ -1,5 +0,0 @@ -class Foo { - constructor() { - super(); - } -} diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/options.json b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/options.json deleted file mode 100644 index a4e0aa5c67..0000000000 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "throws": "super() is only allowed in a derived constructor", - "plugins": ["transform-classes"] -} diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-illegal-non-constructor-call/options.json b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-illegal-non-constructor-call/options.json index 2ff7004be5..84442f571d 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-illegal-non-constructor-call/options.json +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-illegal-non-constructor-call/options.json @@ -1,3 +1,3 @@ { - "throws": "super() is only valid inside a class constructor. Make sure the method name is spelled exactly as 'constructor'." + "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?" } diff --git a/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/input.js b/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/input.js index 53b5bac68e..d2cfab8fba 100644 --- a/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/input.js +++ b/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/input.js @@ -1,5 +1,5 @@ export type GraphQLFormattedError = number; -export type GraphQLFormattedError = { +export type GraphQLFormattedError2 = { message: string, locations?: Array<{ line: number, @@ -7,4 +7,4 @@ export type GraphQLFormattedError = { }> }; export interface foo { p: number } -export interface foo { p: T } +export interface foo2 { p: T } diff --git a/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/output.js b/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/output.js index 9e64ba75a3..7c4a2cffff 100644 --- a/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/output.js +++ b/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/output.js @@ -1,6 +1,6 @@ /*:: export type GraphQLFormattedError = number;*/ -/*:: export type GraphQLFormattedError = { +/*:: export type GraphQLFormattedError2 = { message: string, locations?: Array<{ line: number, @@ -10,4 +10,4 @@ /*:: export interface foo { p: number }*/ -/*:: export interface foo { p: T }*/ +/*:: export interface foo2 { p: T }*/ diff --git a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js index a97695f418..eb188c5c90 100644 --- a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js +++ b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js @@ -1,10 +1,10 @@ class C1<+T, -U> {} function f<+T, -U>() {} type T<+T, -U> = {} -type T = { +p: T } -type T = { -p: T } -type T = { +[k:K]: V } -type T = { -[k:K]: V } +type T1 = { +p: T } +type T2 = { -p: T } +type T3 = { +[k:K]: V } +type T4 = { -[k:K]: V } interface I { +p: T } interface I { -p: T } interface I { +[k:K]: V } diff --git a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-opaque-type-alias/input.js b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-opaque-type-alias/input.js index 53dfc2c874..404f6d84e4 100644 --- a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-opaque-type-alias/input.js +++ b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-opaque-type-alias/input.js @@ -1,6 +1,6 @@ opaque type ID = string; opaque type Foo = Bar -export opaque type Foo = number; +export opaque type Foo1 = number; opaque type union = | {type: "A"} @@ -12,5 +12,5 @@ opaque type overloads = & ((x: number) => string) ; -declare opaque type Foo: Bar; -declare export opaque type Foo: Bar; +declare opaque type Foo2: Bar; +declare export opaque type Fo3: Bar; diff --git a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-alias/input.js b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-alias/input.js index 12bfc22fc8..2718274e2c 100644 --- a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-alias/input.js +++ b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-alias/input.js @@ -1,6 +1,6 @@ type FBID = number; type Foo = Bar -export type Foo = number; +export type Foo1 = number; type union = | {type: "A"} diff --git a/packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/input.js b/packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/input.js deleted file mode 100644 index 47bd620714..0000000000 --- a/packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/input.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; - -const a = () => { - new.target; -}; diff --git a/packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/options.json b/packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/options.json deleted file mode 100644 index bd1ea40794..0000000000 --- a/packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": ["transform-new-target"], - "throws": "new.target must be under a (non-arrow) function or a class." -} diff --git a/scripts/tests/test262/test262_whitelist.txt b/scripts/tests/test262/test262_whitelist.txt index 5d67387a1e..cc2903a3ac 100644 --- a/scripts/tests/test262/test262_whitelist.txt +++ b/scripts/tests/test262/test262_whitelist.txt @@ -284,189 +284,6 @@ built-ins/RegExp/property-escapes/unsupported-property-Line_Break-with-value.js( built-ins/RegExp/property-escapes/unsupported-property-Line_Break-with-value.js(strict mode) built-ins/RegExp/property-escapes/unsupported-property-Line_Break.js(default) built-ins/RegExp/property-escapes/unsupported-property-Line_Break.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration-nested-in-function.js(default) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration-nested-in-function.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-async-function.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-async-generator.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-class.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-class.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-const.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-const.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-function.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-function.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-generator.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-generator.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-let.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-let.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-async-function.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-async-generator.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-class.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-class.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-const.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-const.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-function.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-function.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-generator.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-generator.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-let.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-let.js(strict mode) language/expressions/assignment/destructuring/obj-prop-__proto__dup.js(default) language/expressions/assignment/destructuring/obj-prop-__proto__dup.js(strict mode) language/expressions/async-arrow-function/await-as-param-ident-nested-arrow-parameter-position.js(default) @@ -479,18 +296,6 @@ language/expressions/async-arrow-function/early-errors-arrow-await-in-formals-de language/expressions/async-arrow-function/early-errors-arrow-await-in-formals-default.js(strict mode) language/expressions/async-arrow-function/early-errors-arrow-await-in-formals.js(default) language/expressions/async-arrow-function/early-errors-arrow-await-in-formals.js(strict mode) -language/expressions/async-arrow-function/early-errors-arrow-formals-body-duplicate.js(default) -language/expressions/async-arrow-function/early-errors-arrow-formals-body-duplicate.js(strict mode) -language/expressions/async-function/early-errors-expression-formals-body-duplicate.js(default) -language/expressions/async-function/early-errors-expression-formals-body-duplicate.js(strict mode) -language/expressions/async-function/named-dflt-params-duplicates.js(default) -language/expressions/async-function/nameless-dflt-params-duplicates.js(default) -language/expressions/async-generator/dflt-params-duplicates.js(default) -language/expressions/async-generator/early-errors-expression-formals-body-duplicate-const.js(default) -language/expressions/async-generator/early-errors-expression-formals-body-duplicate-const.js(strict mode) -language/expressions/async-generator/early-errors-expression-formals-body-duplicate-let.js(default) -language/expressions/async-generator/early-errors-expression-formals-body-duplicate-let.js(strict mode) -language/expressions/async-generator/named-dflt-params-duplicates.js(default) language/expressions/class/elements/fields-duplicate-privatenames.js(default) language/expressions/class/elements/fields-duplicate-privatenames.js(strict mode) language/expressions/class/elements/fields-literal-name-static-propname-constructor.js(default) @@ -511,8 +316,6 @@ language/expressions/class/elements/private-derived-cls-indirect-eval-err-contai language/expressions/class/elements/private-derived-cls-indirect-eval-err-contains-supercall.js(strict mode) language/expressions/class/elements/private-methods/prod-private-method-initialize-order.js(default) language/expressions/class/elements/private-methods/prod-private-method-initialize-order.js(strict mode) -language/expressions/class/elements/syntax/early-errors/grammar-ctor-super-no-heritage.js(default) -language/expressions/class/elements/syntax/early-errors/grammar-ctor-super-no-heritage.js(strict mode) language/expressions/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js(default) language/expressions/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js(strict mode) language/expressions/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-get.js(default) @@ -591,21 +394,9 @@ language/expressions/class/elements/syntax/early-errors/invalid-names/method-out language/expressions/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js(strict mode) language/expressions/class/elements/syntax/early-errors/super-private-access-invalid.js(default) language/expressions/class/elements/syntax/early-errors/super-private-access-invalid.js(strict mode) -language/expressions/function/dflt-params-duplicates.js(default) -language/expressions/generators/dflt-params-duplicates.js(default) -language/expressions/object/method-definition/async-gen-meth-dflt-params-duplicates.js(default) -language/expressions/object/method-definition/async-meth-dflt-params-duplicates.js(default) language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js(default) language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js(strict mode) language/expressions/object/method-definition/early-errors-object-method-duplicate-parameters.js(default) -language/expressions/object/method-definition/gen-meth-dflt-params-duplicates.js(default) -language/expressions/object/method-definition/generator-param-redecl-const.js(default) -language/expressions/object/method-definition/generator-param-redecl-const.js(strict mode) -language/expressions/object/method-definition/generator-param-redecl-let.js(default) -language/expressions/object/method-definition/generator-param-redecl-let.js(strict mode) -language/expressions/object/method-definition/meth-dflt-params-duplicates.js(default) -language/expressions/object/method-definition/name-param-redecl.js(default) -language/expressions/object/method-definition/name-param-redecl.js(strict mode) language/expressions/object/method-definition/private-name-early-error-async-fn-inside-class.js(default) language/expressions/object/method-definition/private-name-early-error-async-fn-inside-class.js(strict mode) language/expressions/object/method-definition/private-name-early-error-async-gen-inside-class.js(default) @@ -626,12 +417,8 @@ language/expressions/template-literal/invalid-legacy-octal-escape-sequence.js(de language/expressions/template-literal/invalid-legacy-octal-escape-sequence.js(strict mode) language/expressions/template-literal/unicode-escape-nls-err.js(default) language/expressions/template-literal/unicode-escape-nls-err.js(strict mode) -language/global-code/new.target-arrow.js(default) -language/global-code/new.target-arrow.js(strict mode) language/identifiers/unicode-escape-nls-err.js(default) language/identifiers/unicode-escape-nls-err.js(strict mode) -language/import/dup-bound-names.js(default) -language/import/dup-bound-names.js(strict mode) language/line-terminators/invalid-string-ls.js(default) language/line-terminators/invalid-string-ls.js(strict mode) language/line-terminators/invalid-string-ps.js(default) @@ -816,12 +603,6 @@ language/module-code/early-export-global.js(default) language/module-code/early-export-global.js(strict mode) language/module-code/early-export-unresolvable.js(default) language/module-code/early-export-unresolvable.js(strict mode) -language/module-code/early-lex-and-var.js(default) -language/module-code/early-lex-and-var.js(strict mode) -language/module-code/parse-err-hoist-lex-fun.js(default) -language/module-code/parse-err-hoist-lex-fun.js(strict mode) -language/module-code/parse-err-hoist-lex-gen.js(default) -language/module-code/parse-err-hoist-lex-gen.js(strict mode) language/module-code/privatename-not-valid-earlyerr-module-1.js(default) language/module-code/privatename-not-valid-earlyerr-module-1.js(strict mode) language/module-code/privatename-not-valid-earlyerr-module-2.js(default) @@ -830,10 +611,6 @@ language/module-code/privatename-not-valid-earlyerr-module-3.js(default) language/module-code/privatename-not-valid-earlyerr-module-3.js(strict mode) language/module-code/privatename-not-valid-earlyerr-module-4.js(default) language/module-code/privatename-not-valid-earlyerr-module-4.js(strict mode) -language/statements/async-function/dflt-params-duplicates.js(default) -language/statements/async-function/early-errors-declaration-formals-body-duplicate.js(default) -language/statements/async-function/early-errors-declaration-formals-body-duplicate.js(strict mode) -language/statements/async-generator/dflt-params-duplicates.js(default) language/statements/class/async-gen-meth-escaped-async.js(default) language/statements/class/async-gen-meth-escaped-async.js(strict mode) language/statements/class/async-meth-escaped-async.js(default) @@ -866,8 +643,6 @@ language/statements/class/elements/privatename-not-valid-earlyerr-script-3.js(de language/statements/class/elements/privatename-not-valid-earlyerr-script-3.js(strict mode) language/statements/class/elements/privatename-not-valid-earlyerr-script-4.js(default) language/statements/class/elements/privatename-not-valid-earlyerr-script-4.js(strict mode) -language/statements/class/elements/syntax/early-errors/grammar-ctor-super-no-heritage.js(default) -language/statements/class/elements/syntax/early-errors/grammar-ctor-super-no-heritage.js(strict mode) language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js(default) language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js(strict mode) language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-get.js(default) @@ -946,174 +721,29 @@ language/statements/class/elements/syntax/early-errors/invalid-names/method-outt language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js(strict mode) language/statements/class/elements/syntax/early-errors/super-private-access-invalid.js(default) language/statements/class/elements/syntax/early-errors/super-private-access-invalid.js(strict mode) -language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js(default) -language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js(strict mode) -language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js(default) -language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js(strict mode) -language/statements/const/redeclaration-error-from-within-strict-mode-function-const.js(default) language/statements/for-in/dstr/array-rest-before-elision.js(default) language/statements/for-in/dstr/array-rest-before-elision.js(strict mode) language/statements/for-in/dstr/array-rest-elision-invalid.js(default) language/statements/for-in/dstr/array-rest-elision-invalid.js(strict mode) -language/statements/for-in/head-const-bound-names-dup.js(default) -language/statements/for-in/head-const-bound-names-dup.js(strict mode) language/statements/for-in/head-const-bound-names-in-stmt.js(default) language/statements/for-in/head-const-bound-names-in-stmt.js(strict mode) -language/statements/for-in/head-let-bound-names-dup.js(default) -language/statements/for-in/head-let-bound-names-dup.js(strict mode) language/statements/for-in/head-let-bound-names-in-stmt.js(default) language/statements/for-in/head-let-bound-names-in-stmt.js(strict mode) language/statements/for-of/dstr/array-rest-before-elision.js(default) language/statements/for-of/dstr/array-rest-before-elision.js(strict mode) language/statements/for-of/dstr/array-rest-elision-invalid.js(default) language/statements/for-of/dstr/array-rest-elision-invalid.js(strict mode) -language/statements/for-of/head-const-bound-names-dup.js(default) -language/statements/for-of/head-const-bound-names-dup.js(strict mode) language/statements/for-of/head-const-bound-names-in-stmt.js(default) language/statements/for-of/head-const-bound-names-in-stmt.js(strict mode) language/statements/for-of/head-decl-no-expr.js(default) language/statements/for-of/head-decl-no-expr.js(strict mode) language/statements/for-of/head-expr-no-expr.js(default) language/statements/for-of/head-expr-no-expr.js(strict mode) -language/statements/for-of/head-let-bound-names-dup.js(default) -language/statements/for-of/head-let-bound-names-dup.js(strict mode) language/statements/for-of/head-let-bound-names-in-stmt.js(default) language/statements/for-of/head-let-bound-names-in-stmt.js(strict mode) language/statements/for-of/head-var-no-expr.js(default) language/statements/for-of/head-var-no-expr.js(strict mode) language/statements/for/head-let-bound-names-in-stmt.js(default) language/statements/for/head-let-bound-names-in-stmt.js(strict mode) -language/statements/function/dflt-params-duplicates.js(default) -language/statements/generators/dflt-params-duplicates.js(default) -language/statements/let/redeclaration-error-from-within-strict-mode-function.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/try/early-catch-function.js(default) -language/statements/try/early-catch-function.js(strict mode) -language/statements/try/early-catch-lex.js(default) -language/statements/try/early-catch-lex.js(strict mode) language/statements/try/early-catch-var.js(default) language/statements/try/early-catch-var.js(strict mode) \ No newline at end of file