Refactor parsing object members (#9607)

* Refactor parsing object members

* Ensure decorators on rest don’t swallow decorators silently

* Use hasPrecedingLineBreak

* Add test for async with linebreak

* Update flow whitelist
This commit is contained in:
Daniel Tschinder
2019-02-28 11:42:12 -08:00
committed by GitHub
parent 208195f425
commit 98ab1b6428
51 changed files with 1060 additions and 179 deletions

View File

@@ -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 &&

View File

@@ -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`);
}
}

View File

@@ -126,16 +126,24 @@ export default (superClass: Class<Parser>): Class<Parser> =>
}
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");
}

View File

@@ -570,7 +570,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
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");
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (1:18)"
"throws": "Rest element must be last element (1:18)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (3:13)"
"throws": "Rest element must be last element (3:13)"
}

View File

@@ -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)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest element must be the last element (1:1)"
"throws": "Rest element must be last element (1:1)"
}

View File

@@ -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)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (3:13)"
"throws": "Rest element must be last element (3:13)"
}

View File

@@ -0,0 +1,4 @@
({
async
foo() {}
})

View File

@@ -0,0 +1,3 @@
{
"throws": "Unexpected token, expected \",\" (3:4)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (1:18)"
"throws": "Rest element must be last element (1:18)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (1:5)"
"throws": "Rest element must be last element (1:5)"
}

View File

@@ -1 +0,0 @@
({ __proto__, __proto__: 2 })

View File

@@ -1,3 +0,0 @@
{
"throws": "Redefinition of __proto__ property (1:14)"
}

View File

@@ -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)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:8)"
"throws": "Unexpected token (1:8)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:9)"
"throws": "Unexpected token (1:9)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:18)"
"throws": "Unexpected token (1:18)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:18)"
"throws": "Unexpected token (1:18)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:8)"
"throws": "Unexpected token, expected \",\" (1:10)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:18)"
"throws": "Unexpected token, expected \",\" (1:20)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:8)"
"throws": "Unexpected token (1:8)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "Invalid rest operator's argument (1:18)"
"throws": "Unexpected token (1:18)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest property must be the last property (1:10)"
"throws": "Rest element must be last element (1:10)"
}

View File

@@ -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)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest property must be the last property (1:13)"
"throws": "Rest element must be last element (1:13)"
}

View File

@@ -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)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest property must be the last property (1:2)"
"throws": "Rest element must be last element (1:2)"
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (1:5)"
"throws": "Rest element must be last element (1:5)"
}

View File

@@ -1,3 +0,0 @@
{
"throws": "Redefinition of __proto__ property (1:20)"
}

View File

@@ -1,3 +0,0 @@
{
"throws": "Redefinition of __proto__ property (1:22)"
}

View File

@@ -1,3 +0,0 @@
{
"throws": "Redefinition of __proto__ property (1:14)"
}

View File

@@ -1,3 +0,0 @@
{
"throws": "Redefinition of __proto__ property (1:14)"
}

View File

@@ -1,3 +0,0 @@
{
"throws": "Redefinition of __proto__ property (1:14)"
}

View File

@@ -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": []
}
}

View File

@@ -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": []
}
}

View File

@@ -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": []
}
}

View File

@@ -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": []
}
}

View File

@@ -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": []
}
}

View File

@@ -1,3 +1,3 @@
{
"throws": "The rest parameter must be the last parameter (1:18)"
"throws": "Rest element must be last element (1:18)"
}

View File

@@ -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)"
}