From 98ab1b6428e797088bb6245f81963dae174be2f5 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Thu, 28 Feb 2019 11:42:12 -0800 Subject: [PATCH] Refactor parsing object members (#9607) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refactor parsing object members * Ensure decorators on rest don’t swallow decorators silently * Use hasPrecedingLineBreak * Add test for async with linebreak * Update flow whitelist --- .../babel-parser/src/parser/expression.js | 213 ++++++++++-------- packages/babel-parser/src/parser/lval.js | 35 +-- packages/babel-parser/src/plugins/estree.js | 14 +- .../babel-parser/src/plugins/typescript.js | 2 +- .../core/uncategorised/396/options.json | 2 +- .../core/uncategorised/555/options.json | 2 +- .../comma-after-rest/options.json | 2 +- .../invalid-location/options.json | 2 +- .../comma-after-rest-param/options.json | 2 +- .../invalid-rest-in-params/options.json | 2 +- .../object/async-method-linebreak/input.js | 4 + .../async-method-linebreak/options.json | 3 + .../es2015/uncategorised/277/options.json | 2 +- .../es2015/uncategorised/283/options.json | 2 +- .../es2015/uncategorised/353/input.js | 1 - .../es2015/uncategorised/353/options.json | 3 - .../options.json | 2 +- .../es2018/object-rest-spread/16/options.json | 2 +- .../es2018/object-rest-spread/17/options.json | 2 +- .../es2018/object-rest-spread/19/options.json | 2 +- .../es2018/object-rest-spread/20/options.json | 2 +- .../es2018/object-rest-spread/22/options.json | 2 +- .../es2018/object-rest-spread/23/options.json | 2 +- .../es2018/object-rest-spread/25/options.json | 2 +- .../es2018/object-rest-spread/26/options.json | 2 +- .../es2018/object-rest-spread/7/options.json | 2 +- .../es2018/object-rest-spread/8/options.json | 2 +- .../es2018/object-rest-spread/9/options.json | 2 +- .../comma-after-rest/options.json | 2 +- .../options.json | 2 +- .../arrow-with-multiple-rest/options.json | 2 +- .../options.json | 3 - .../options.json | 3 - .../options.json | 3 - .../options.json | 3 - .../invalid-proto-shorthands/options.json | 3 - .../input.js | 0 .../proto-identifier-shorthand/output.json | 176 +++++++++++++++ .../input.js | 0 .../proto-literal-shorthand/output.json | 179 +++++++++++++++ .../input.js | 0 .../proto-shorthand-identifier/output.json | 176 +++++++++++++++ .../input.js | 0 .../proto-shorthand-literal/output.json | 179 +++++++++++++++ .../input.js | 0 .../proto-shorthands/output.json | 181 +++++++++++++++ .../invalid-syntax/migrated_0258/options.json | 2 +- .../types/tuple-rest-invalid/options.json | 2 +- scripts/tests/flow/flow_tests_whitelist.txt | 1 - .../test262/run_babel_parser_test262_utils.js | 2 +- scripts/tests/test262/test262_whitelist.txt | 5 - 51 files changed, 1060 insertions(+), 179 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/options.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/353/input.js delete mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/353/options.json delete mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-shorthand/options.json delete mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-shorthand/options.json delete mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-identifier/options.json delete mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-literal/options.json delete mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthands/options.json rename packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/{invalid-proto-identifier-shorthand => proto-identifier-shorthand}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-identifier-shorthand/output.json rename packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/{invalid-proto-literal-shorthand => proto-literal-shorthand}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-literal-shorthand/output.json rename packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/{invalid-proto-shorthand-identifier => proto-shorthand-identifier}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-identifier/output.json rename packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/{invalid-proto-shorthand-literal => proto-shorthand-literal}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-literal/output.json rename packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/{invalid-proto-shorthands => proto-shorthands}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthands/output.json diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 63c5cbe0bb..9b05a76d56 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -67,10 +67,18 @@ export default class ExpressionParser extends LValParser { // strict mode, init properties are also not allowed to be repeated. checkPropClash( - prop: N.ObjectMember, + prop: N.ObjectMember | N.SpreadElement, propHash: { [key: string]: boolean }, ): void { - if (prop.computed || prop.kind) return; + if ( + prop.type === "SpreadElement" || + prop.computed || + prop.kind || + // $FlowIgnore + prop.shorthand + ) { + return; + } const key = prop.key; // It is either an Identifier or a String/NumericLiteral @@ -197,13 +205,10 @@ export default class ExpressionParser extends LValParser { this.checkLVal(left, undefined, undefined, "assignment expression"); let patternErrorMsg; - let elementName; if (left.type === "ObjectPattern") { patternErrorMsg = "`({a}) = 0` use `({a} = 0)`"; - elementName = "property"; } else if (left.type === "ArrayPattern") { patternErrorMsg = "`([a]) = 0` use `([a] = 0)`"; - elementName = "element"; } if (patternErrorMsg && left.extra && left.extra.parenthesized) { @@ -213,7 +218,7 @@ export default class ExpressionParser extends LValParser { ); } - if (elementName) this.checkCommaAfterRestFromSpread(elementName); + if (patternErrorMsg) this.checkCommaAfterRestFromSpread(); this.state.commaAfterSpreadAt = oldCommaAfterSpreadAt; this.next(); @@ -639,7 +644,7 @@ export default class ExpressionParser extends LValParser { if (possibleAsync && this.shouldParseAsyncArrow()) { state.stop = true; - this.checkCommaAfterRestFromSpread("parameter"); + this.checkCommaAfterRestFromSpread(); node = this.parseAsyncArrowFromCallExpression( this.startNodeAt(startPos, startLoc), @@ -1207,13 +1212,13 @@ export default class ExpressionParser extends LValParser { spreadStart = this.state.start; exprList.push( this.parseParenItem( - this.parseRest(), + this.parseRestBinding(), spreadNodeStartPos, spreadNodeStartLoc, ), ); - this.checkCommaAfterRest(tt.parenR, "parameter"); + this.checkCommaAfterRest(); break; } else { @@ -1409,7 +1414,6 @@ export default class ExpressionParser extends LValParser { isPattern: boolean, refShorthandDefaultPos?: ?Pos, ): T { - let decorators = []; const propHash: any = Object.create(null); let first = true; const node = this.startNode(); @@ -1425,90 +1429,11 @@ export default class ExpressionParser extends LValParser { if (this.eat(tt.braceR)) break; } - if (this.match(tt.at)) { - if (this.hasPlugin("decorators")) { - this.raise( - this.state.start, - "Stage 2 decorators disallow object literal property decorators", - ); - } else { - // we needn't check if decorators (stage 0) plugin is enabled since it's checked by - // the call to this.parseDecorator - while (this.match(tt.at)) { - decorators.push(this.parseDecorator()); - } - } - } - - let prop = this.startNode(), - isGenerator = false, - isAsync = false, - startPos, - startLoc; - if (decorators.length) { - prop.decorators = decorators; - decorators = []; - } - - if (this.match(tt.ellipsis)) { - prop = this.parseSpread(isPattern ? { start: 0 } : undefined); - node.properties.push(prop); - if (isPattern) { - this.toAssignable(prop, true, "object pattern"); - this.checkCommaAfterRest(tt.braceR, "property"); - this.expect(tt.braceR); - break; - } - continue; - } - - prop.method = false; - - if (isPattern || refShorthandDefaultPos) { - startPos = this.state.start; - startLoc = this.state.startLoc; - } - - if (!isPattern) { - isGenerator = this.eat(tt.star); - } - - const containsEsc = this.state.containsEsc; - - if (!isPattern && this.isContextual("async")) { - if (isGenerator) this.unexpected(); - - const asyncId = this.parseIdentifier(); - if ( - this.match(tt.colon) || - this.match(tt.parenL) || - this.match(tt.braceR) || - this.match(tt.eq) || - this.match(tt.comma) - ) { - prop.key = asyncId; - prop.computed = false; - } else { - isAsync = true; - isGenerator = this.eat(tt.star); - this.parsePropertyName(prop); - } - } else { - this.parsePropertyName(prop); - } - - this.parseObjPropValue( - prop, - startPos, - startLoc, - isGenerator, - isAsync, - isPattern, - refShorthandDefaultPos, - containsEsc, - ); - this.checkPropClash(prop, propHash); + const prop = this.parseObjectMember(isPattern, refShorthandDefaultPos); + // $FlowIgnore RestElement will never be returned if !isPattern + if (!isPattern) this.checkPropClash(prop, propHash); + // $FlowIgnore if (prop.shorthand) { this.addExtra(prop, "shorthand", true); } @@ -1516,19 +1441,107 @@ export default class ExpressionParser extends LValParser { node.properties.push(prop); } - if (decorators.length) { - this.raise( - this.state.start, - "You have trailing decorators with no property", - ); - } - return this.finishNode( node, isPattern ? "ObjectPattern" : "ObjectExpression", ); } + isAsyncProp(prop: N.ObjectProperty): boolean { + return ( + !prop.computed && + prop.key.type === "Identifier" && + prop.key.name === "async" && + (this.match(tt.name) || + this.match(tt.num) || + this.match(tt.string) || + this.match(tt.bracketL) || + this.state.type.keyword || + this.match(tt.star)) && + !this.hasPrecedingLineBreak() + ); + } + + parseObjectMember( + isPattern: boolean, + refShorthandDefaultPos: ?Pos, + ): N.ObjectMember | N.SpreadElement | N.RestElement { + let decorators = []; + if (this.match(tt.at)) { + if (this.hasPlugin("decorators")) { + this.raise( + this.state.start, + "Stage 2 decorators disallow object literal property decorators", + ); + } else { + // we needn't check if decorators (stage 0) plugin is enabled since it's checked by + // the call to this.parseDecorator + while (this.match(tt.at)) { + decorators.push(this.parseDecorator()); + } + } + } + + const prop = this.startNode(); + let isGenerator = false; + let isAsync = false; + let startPos; + let startLoc; + + if (this.match(tt.ellipsis)) { + if (decorators.length) this.unexpected(); + if (isPattern) { + this.next(); + // Don't use parseRestBinding() as we only allow Identifier here. + prop.argument = this.parseIdentifier(); + this.checkCommaAfterRest(); + return this.finishNode(prop, "RestElement"); + } + + return this.parseSpread(); + } + + if (decorators.length) { + prop.decorators = decorators; + decorators = []; + } + + prop.method = false; + + if (isPattern || refShorthandDefaultPos) { + startPos = this.state.start; + startLoc = this.state.startLoc; + } + + if (!isPattern) { + isGenerator = this.eat(tt.star); + } + + const containsEsc = this.state.containsEsc; + this.parsePropertyName(prop); + + if (!isPattern && !containsEsc && !isGenerator && this.isAsyncProp(prop)) { + isAsync = true; + isGenerator = this.eat(tt.star); + this.parsePropertyName(prop); + } else { + isAsync = false; + } + + this.parseObjPropValue( + prop, + startPos, + startLoc, + isGenerator, + isAsync, + isPattern, + refShorthandDefaultPos, + containsEsc, + ); + + return prop; + } + isGetterOrSetterMethod(prop: N.ObjectMethod, isPattern: boolean): boolean { return ( !isPattern && diff --git a/packages/babel-parser/src/parser/lval.js b/packages/babel-parser/src/parser/lval.js index 1711b7ae7d..dd02c8c974 100644 --- a/packages/babel-parser/src/parser/lval.js +++ b/packages/babel-parser/src/parser/lval.js @@ -122,7 +122,7 @@ export default class LValParser extends NodeUtils { this.raise(prop.key.start, error); } else if (prop.type === "SpreadElement" && !isLast) { - this.raiseRestNotLast(prop.start, "property"); + this.raiseRestNotLast(prop.start); } else { this.toAssignable(prop, isBinding, "object destructuring pattern"); } @@ -160,7 +160,7 @@ export default class LValParser extends NodeUtils { if (elt) { this.toAssignable(elt, isBinding, contextDescription); if (elt.type === "RestElement") { - this.raiseRestNotLast(elt.start, "element"); + this.raiseRestNotLast(elt.start); } } } @@ -213,7 +213,7 @@ export default class LValParser extends NodeUtils { return this.finishNode(node, "SpreadElement"); } - parseRest(): RestElement { + parseRestBinding(): RestElement { const node = this.startNode(); this.next(); node.argument = this.parseBindingAtom(); @@ -260,13 +260,8 @@ export default class LValParser extends NodeUtils { } else if (this.eat(close)) { break; } else if (this.match(tt.ellipsis)) { - elts.push(this.parseAssignableListItemTypes(this.parseRest())); - this.checkCommaAfterRest( - close, - this.scope.inFunction && this.state.inParameters - ? "parameter" - : "element", - ); + elts.push(this.parseAssignableListItemTypes(this.parseRestBinding())); + this.checkCommaAfterRest(); this.expect(close); break; } else { @@ -441,27 +436,19 @@ export default class LValParser extends NodeUtils { } } - checkCommaAfterRest(close: TokenType, kind: string): void { + checkCommaAfterRest(): void { if (this.match(tt.comma)) { - if (this.lookahead().type === close) { - this.raiseCommaAfterRest(this.state.start, kind); - } else { - this.raiseRestNotLast(this.state.start, kind); - } + this.raiseRestNotLast(this.state.start); } } - checkCommaAfterRestFromSpread(kind: string): void { + checkCommaAfterRestFromSpread(): void { if (this.state.commaAfterSpreadAt > -1) { - this.raiseCommaAfterRest(this.state.commaAfterSpreadAt, kind); + this.raiseRestNotLast(this.state.commaAfterSpreadAt); } } - raiseCommaAfterRest(pos: number, kind: string) { - this.raise(pos, `A trailing comma is not permitted after the rest ${kind}`); - } - - raiseRestNotLast(pos: number, kind: string) { - this.raise(pos, `The rest ${kind} must be the last ${kind}`); + raiseRestNotLast(pos: number) { + this.raise(pos, `Rest element must be last element`); } } diff --git a/packages/babel-parser/src/plugins/estree.js b/packages/babel-parser/src/plugins/estree.js index 07891f3086..38e7e2e01c 100644 --- a/packages/babel-parser/src/plugins/estree.js +++ b/packages/babel-parser/src/plugins/estree.js @@ -126,16 +126,24 @@ export default (superClass: Class): Class => } checkPropClash( - prop: N.ObjectMember, + prop: N.ObjectMember | N.SpreadElement, propHash: { [key: string]: boolean }, ): void { - if (prop.computed || !isSimpleProperty(prop)) return; + if ( + prop.type === "SpreadElement" || + prop.computed || + prop.method || + // $FlowIgnore + prop.shorthand + ) { + return; + } const key = prop.key; // It is either an Identifier or a String/NumericLiteral const name = key.type === "Identifier" ? key.name : String(key.value); - if (name === "__proto__") { + if (name === "__proto__" && prop.kind === "init") { if (propHash.proto) { this.raise(key.start, "Redefinition of __proto__ property"); } diff --git a/packages/babel-parser/src/plugins/typescript.js b/packages/babel-parser/src/plugins/typescript.js index c511536613..7bc3623d78 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -570,7 +570,7 @@ export default (superClass: Class): Class => const restNode: N.TsRestType = this.startNode(); this.next(); // skips ellipsis restNode.typeAnnotation = this.tsParseType(); - this.checkCommaAfterRest(tt.bracketR, "type"); + this.checkCommaAfterRest(); return this.finishNode(restNode, "TSRestType"); } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/396/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/396/options.json index 029befceda..2e1b1cc3aa 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/396/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/396/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (1:18)" + "throws": "Rest element must be last element (1:18)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/555/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/555/options.json index baad06556f..c1c6450ba3 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/555/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/555/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (3:13)" + "throws": "Rest element must be last element (3:13)" } diff --git a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/options.json b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/options.json index a85e470aeb..daa827f45c 100644 --- a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/options.json +++ b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/options.json @@ -1,3 +1,3 @@ { - "throws": "A trailing comma is not permitted after the rest element (1:5)" + "throws": "Rest element must be last element (1:5)" } diff --git a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/options.json b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/options.json index 083dcaaa2c..0dac59b7a8 100644 --- a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/options.json +++ b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest element must be the last element (1:1)" + "throws": "Rest element must be last element (1:1)" } diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json index d866b41af7..65ed8c6389 100644 --- a/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json +++ b/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json @@ -1,3 +1,3 @@ { - "throws": "A trailing comma is not permitted after the rest parameter (1:8)" + "throws": "Rest element must be last element (1:8)" } diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/options.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/options.json index baad06556f..c1c6450ba3 100644 --- a/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/options.json +++ b/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (3:13)" + "throws": "Rest element must be last element (3:13)" } diff --git a/packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/input.js b/packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/input.js new file mode 100644 index 0000000000..f50ae43d06 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/input.js @@ -0,0 +1,4 @@ +({ + async + foo() {} +}) diff --git a/packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/options.json b/packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/options.json new file mode 100644 index 0000000000..978486d6a5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \",\" (3:4)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/277/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/277/options.json index 029befceda..2e1b1cc3aa 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/277/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/277/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (1:18)" + "throws": "Rest element must be last element (1:18)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/283/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/283/options.json index 3ead3a4299..daa827f45c 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/283/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/283/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (1:5)" + "throws": "Rest element must be last element (1:5)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/353/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/353/input.js deleted file mode 100644 index 727c567cc1..0000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/353/input.js +++ /dev/null @@ -1 +0,0 @@ -({ __proto__, __proto__: 2 }) \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/353/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/353/options.json deleted file mode 100644 index a8b5ad2f5b..0000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/353/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/options.json index 231d5fccd5..f686fb60b4 100644 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/options.json +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/options.json @@ -1,3 +1,3 @@ { - "throws": "A trailing comma is not permitted after the rest parameter (1:11)" + "throws": "Rest element must be last element (1:11)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/16/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/16/options.json index f65c23001f..9ce9658f7d 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/16/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/16/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:8)" + "throws": "Unexpected token (1:8)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/17/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/17/options.json index bf0116a7b0..2a28555f76 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/17/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/17/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:9)" + "throws": "Unexpected token (1:9)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/19/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/19/options.json index 6a9895dd9d..b8b06c3a03 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/19/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/19/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:18)" + "throws": "Unexpected token (1:18)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/20/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/20/options.json index 6a9895dd9d..b8b06c3a03 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/20/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/20/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:18)" + "throws": "Unexpected token (1:18)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/22/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/22/options.json index f65c23001f..08b79c43d6 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/22/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/22/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:8)" + "throws": "Unexpected token, expected \",\" (1:10)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/23/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/23/options.json index 6a9895dd9d..81e7a97e3f 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/23/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/23/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:18)" + "throws": "Unexpected token, expected \",\" (1:20)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/25/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/25/options.json index f65c23001f..9ce9658f7d 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/25/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/25/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:8)" + "throws": "Unexpected token (1:8)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/26/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/26/options.json index 6a9895dd9d..b8b06c3a03 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/26/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/26/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:18)" + "throws": "Unexpected token (1:18)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/options.json index 253a786581..b86f80dc4a 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest property must be the last property (1:10)" + "throws": "Rest element must be last element (1:10)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/options.json index e5efb19664..c49db16e28 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/options.json @@ -1,3 +1,3 @@ { - "throws": "A trailing comma is not permitted after the rest property (1:16)" + "throws": "Rest element must be last element (1:16)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/options.json index e1bf843ed1..e9effa60cb 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest property must be the last property (1:13)" + "throws": "Rest element must be last element (1:13)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/options.json index a19bb078b1..935d087d7e 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/options.json @@ -1,3 +1,3 @@ { - "throws": "A trailing comma is not permitted after the rest property (1:6)" + "throws": "Rest element must be last element (1:6)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/options.json index 015adf82cd..b708967fd2 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest property must be the last property (1:2)" + "throws": "Rest element must be last element (1:2)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/options.json index 3ead3a4299..daa827f45c 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (1:5)" + "throws": "Rest element must be last element (1:5)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-shorthand/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-shorthand/options.json deleted file mode 100644 index 5c966843f4..0000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-shorthand/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:20)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-shorthand/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-shorthand/options.json deleted file mode 100644 index e19950ad14..0000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-shorthand/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:22)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-identifier/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-identifier/options.json deleted file mode 100644 index a8b5ad2f5b..0000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-identifier/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-literal/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-literal/options.json deleted file mode 100644 index a8b5ad2f5b..0000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-literal/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthands/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthands/options.json deleted file mode 100644 index a8b5ad2f5b..0000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthands/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-shorthand/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-identifier-shorthand/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-shorthand/input.js rename to packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-identifier-shorthand/input.js diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-identifier-shorthand/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-identifier-shorthand/output.json new file mode 100644 index 0000000000..20867c4f1d --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-identifier-shorthand/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + } + } + }, + { + "type": "ObjectProperty", + "start": 20, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 20, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 20, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "extra": { + "shorthand": true + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-shorthand/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-literal-shorthand/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-shorthand/input.js rename to packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-literal-shorthand/input.js diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-literal-shorthand/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-literal-shorthand/output.json new file mode 100644 index 0000000000..43f28e81ab --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-literal-shorthand/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "method": false, + "key": { + "type": "StringLiteral", + "start": 3, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": "__proto__", + "raw": "\"__proto__\"" + }, + "value": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 16, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + } + } + } + }, + { + "type": "ObjectProperty", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "extra": { + "shorthand": true + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-identifier/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-identifier/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-identifier/input.js rename to packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-identifier/input.js diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-identifier/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-identifier/output.json new file mode 100644 index 0000000000..28fc9127cd --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-identifier/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 25, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 29 + } + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-literal/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-literal/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-literal/input.js rename to packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-literal/input.js diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-literal/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-literal/output.json new file mode 100644 index 0000000000..5bfefd1a39 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-literal/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start": 14, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "method": false, + "key": { + "type": "StringLiteral", + "start": 14, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "extra": { + "rawValue": "__proto__", + "raw": "\"__proto__\"" + }, + "value": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 27, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 31 + } + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthands/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthands/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthands/input.js rename to packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthands/input.js diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthands/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthands/output.json new file mode 100644 index 0000000000..23f3d43707 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthands/output.json @@ -0,0 +1,181 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "extra": { + "shorthand": true + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/options.json index 029befceda..2e1b1cc3aa 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (1:18)" + "throws": "Rest element must be last element (1:18)" } diff --git a/packages/babel-parser/test/fixtures/typescript/types/tuple-rest-invalid/options.json b/packages/babel-parser/test/fixtures/typescript/types/tuple-rest-invalid/options.json index a500c245e7..82b4f09fc9 100644 --- a/packages/babel-parser/test/fixtures/typescript/types/tuple-rest-invalid/options.json +++ b/packages/babel-parser/test/fixtures/typescript/types/tuple-rest-invalid/options.json @@ -1,5 +1,5 @@ { "sourceType": "module", "plugins": ["typescript"], - "throws": "The rest type must be the last type (1:19)" + "throws": "Rest element must be last element (1:19)" } diff --git a/scripts/tests/flow/flow_tests_whitelist.txt b/scripts/tests/flow/flow_tests_whitelist.txt index 4c850ac527..60ee5e0e6e 100644 --- a/scripts/tests/flow/flow_tests_whitelist.txt +++ b/scripts/tests/flow/flow_tests_whitelist.txt @@ -10,7 +10,6 @@ JSX_invalid/migrated_0000.js arrow_function_invalid/migrated_0002.js -async_await/async_generic_method.js async_await/migrated_0007.js async_await/migrated_0020.js async_await/migrated_0024.js diff --git a/scripts/tests/test262/run_babel_parser_test262_utils.js b/scripts/tests/test262/run_babel_parser_test262_utils.js index 99c173dab6..974e4a88e7 100644 --- a/scripts/tests/test262/run_babel_parser_test262_utils.js +++ b/scripts/tests/test262/run_babel_parser_test262_utils.js @@ -229,7 +229,7 @@ exports.updateWhitelist = function(filename, summary) { return line; }) .filter(function(line) { - return line !== null; + return line !== null && line !== ""; }) .concat(toAdd) .sort() diff --git a/scripts/tests/test262/test262_whitelist.txt b/scripts/tests/test262/test262_whitelist.txt index 2dc847d203..03e75b2222 100644 --- a/scripts/tests/test262/test262_whitelist.txt +++ b/scripts/tests/test262/test262_whitelist.txt @@ -1,4 +1,3 @@ - annexB/language/statements/for-in/bare-initializer.js(default) annexB/language/statements/for-in/bare-initializer.js(strict mode) built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_F-negated.js(default) @@ -406,10 +405,6 @@ 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/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/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) language/expressions/object/method-definition/private-name-early-error-async-gen-inside-class.js(strict mode) language/expressions/object/method-definition/private-name-early-error-gen-inside-class.js(default)