Recover from shorthand assign exprs (#13968)

* refactor: avoid duplicate property access

* refactor: tweak parseMember

* polish: recover from shorthand assign in exprs
This commit is contained in:
Huáng Jùnliàng 2021-11-19 10:22:29 -05:00 committed by GitHub
parent d017d43535
commit a470f7b479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 817 additions and 52 deletions

View File

@ -78,6 +78,7 @@ export const ErrorMessages = makeErrorTemplates(
ImportCallSpreadArgument: "`...` is not allowed in `import()`.", ImportCallSpreadArgument: "`...` is not allowed in `import()`.",
InvalidBigIntLiteral: "Invalid BigIntLiteral.", InvalidBigIntLiteral: "Invalid BigIntLiteral.",
InvalidCodePoint: "Code point out of bounds.", InvalidCodePoint: "Code point out of bounds.",
InvalidCoverInitializedName: "Invalid shorthand property initializer.",
InvalidDecimal: "Invalid decimal.", InvalidDecimal: "Invalid decimal.",
InvalidDigit: "Expected number in radix %0.", InvalidDigit: "Expected number in radix %0.",
InvalidEscapeSequence: "Bad character escape sequence.", InvalidEscapeSequence: "Bad character escape sequence.",

View File

@ -770,24 +770,17 @@ export default class ExpressionParser extends LValParser {
const node = this.startNodeAt(startPos, startLoc); const node = this.startNodeAt(startPos, startLoc);
node.object = base; node.object = base;
node.computed = computed; node.computed = computed;
const privateName = if (computed) {
!computed && this.match(tt.privateName) && this.state.value; node.property = this.parseExpression();
const property = computed this.expect(tt.bracketR);
? this.parseExpression() } else if (this.match(tt.privateName)) {
: privateName if (base.type === "Super") {
? this.parsePrivateName()
: this.parseIdentifier(true);
if (privateName !== false) {
if (node.object.type === "Super") {
this.raise(startPos, Errors.SuperPrivateField); this.raise(startPos, Errors.SuperPrivateField);
} }
this.classScope.usePrivateName(privateName, property.start); this.classScope.usePrivateName(this.state.value, this.state.start);
} node.property = this.parsePrivateName();
node.property = property; } else {
node.property = this.parseIdentifier(true);
if (computed) {
this.expect(tt.bracketR);
} }
if (state.optionalChainMember) { if (state.optionalChainMember) {
@ -2137,7 +2130,7 @@ export default class ExpressionParser extends LValParser {
if (!prop.computed && prop.key.type === "Identifier") { if (!prop.computed && prop.key.type === "Identifier") {
// PropertyDefinition: // PropertyDefinition:
// IdentifierReference // IdentifierReference
// CoveredInitializedName // CoverInitializedName
// Note: `{ eval } = {}` will be checked in `checkLVal` later. // Note: `{ eval } = {}` will be checked in `checkLVal` later.
this.checkReservedWord(prop.key.name, prop.key.start, true, false); this.checkReservedWord(prop.key.name, prop.key.start, true, false);
@ -2147,9 +2140,14 @@ export default class ExpressionParser extends LValParser {
startLoc, startLoc,
cloneIdentifier(prop.key), cloneIdentifier(prop.key),
); );
} else if (this.match(tt.eq) && refExpressionErrors) { } else if (this.match(tt.eq)) {
if (refExpressionErrors.shorthandAssign === -1) { const shorthandAssign = this.state.start;
refExpressionErrors.shorthandAssign = this.state.start; if (refExpressionErrors != null) {
if (refExpressionErrors.shorthandAssign === -1) {
refExpressionErrors.shorthandAssign = shorthandAssign;
}
} else {
this.raise(shorthandAssign, Errors.InvalidCoverInitializedName);
} }
prop.value = this.parseMaybeDefault( prop.value = this.parseMaybeDefault(
startPos, startPos,

View File

@ -270,7 +270,7 @@ export default class UtilParser extends Tokenizer {
return hasErrors; return hasErrors;
} else if (hasErrors) { } else if (hasErrors) {
if (shorthandAssign >= 0) { if (shorthandAssign >= 0) {
this.unexpected(shorthandAssign); this.raise(shorthandAssign, Errors.InvalidCoverInitializedName);
} }
if (doubleProto >= 0) { if (doubleProto >= 0) {
this.raise(doubleProto, Errors.DuplicateProto); this.raise(doubleProto, Errors.DuplicateProto);

View File

@ -61,11 +61,12 @@ export default class ClassScopeHandler {
elementType: ClassElementTypes, elementType: ClassElementTypes,
pos: number, pos: number,
) { ) {
const classScope = this.current(); const { privateNames, loneAccessors, undefinedPrivateNames } =
let redefined = classScope.privateNames.has(name); this.current();
let redefined = privateNames.has(name);
if (elementType & CLASS_ELEMENT_KIND_ACCESSOR) { if (elementType & CLASS_ELEMENT_KIND_ACCESSOR) {
const accessor = redefined && classScope.loneAccessors.get(name); const accessor = redefined && loneAccessors.get(name);
if (accessor) { if (accessor) {
const oldStatic = accessor & CLASS_ELEMENT_FLAG_STATIC; const oldStatic = accessor & CLASS_ELEMENT_FLAG_STATIC;
const newStatic = elementType & CLASS_ELEMENT_FLAG_STATIC; const newStatic = elementType & CLASS_ELEMENT_FLAG_STATIC;
@ -78,9 +79,9 @@ export default class ClassScopeHandler {
// they have the same placement (static or not). // they have the same placement (static or not).
redefined = oldKind === newKind || oldStatic !== newStatic; redefined = oldKind === newKind || oldStatic !== newStatic;
if (!redefined) classScope.loneAccessors.delete(name); if (!redefined) loneAccessors.delete(name);
} else if (!redefined) { } else if (!redefined) {
classScope.loneAccessors.set(name, elementType); loneAccessors.set(name, elementType);
} }
} }
@ -88,8 +89,8 @@ export default class ClassScopeHandler {
this.raise(pos, Errors.PrivateNameRedeclaration, name); this.raise(pos, Errors.PrivateNameRedeclaration, name);
} }
classScope.privateNames.add(name); privateNames.add(name);
classScope.undefinedPrivateNames.delete(name); undefinedPrivateNames.delete(name);
} }
usePrivateName(name: string, pos: number) { usePrivateName(name: string, pos: number) {

View File

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

View File

@ -1,3 +0,0 @@
{
"throws": "Unexpected token (2:6)"
}

View File

@ -0,0 +1,102 @@
{
"type": "File",
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":2}},
"errors": [
"SyntaxError: Invalid shorthand property initializer. (3:6)"
],
"program": {
"type": "Program",
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":2}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "VariableDeclaration",
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":2}},
"declarations": [
{
"type": "VariableDeclarator",
"start":6,"end":43,"loc":{"start":{"line":1,"column":6},"end":{"line":4,"column":1}},
"id": {
"type": "Identifier",
"start":6,"end":9,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":9},"identifierName":"obj"},
"name": "obj"
},
"init": {
"type": "ObjectExpression",
"start":12,"end":43,"loc":{"start":{"line":1,"column":12},"end":{"line":4,"column":1}},
"properties": [
{
"type": "ObjectProperty",
"start":16,"end":28,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":14}},
"method": false,
"key": {
"type": "Identifier",
"start":16,"end":19,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":5},"identifierName":"bar"},
"name": "bar"
},
"computed": false,
"shorthand": false,
"value": {
"type": "AssignmentExpression",
"start":21,"end":28,"loc":{"start":{"line":2,"column":7},"end":{"line":2,"column":14}},
"operator": "=",
"left": {
"type": "Identifier",
"start":21,"end":22,"loc":{"start":{"line":2,"column":7},"end":{"line":2,"column":8},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "NumericLiteral",
"start":25,"end":28,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":14}},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
}
}
},
{
"type": "ObjectProperty",
"start":32,"end":41,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":11}},
"method": false,
"key": {
"type": "Identifier",
"start":32,"end":35,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":5},"identifierName":"foo"},
"name": "foo"
},
"computed": false,
"shorthand": true,
"value": {
"type": "AssignmentPattern",
"start":32,"end":41,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":11}},
"left": {
"type": "Identifier",
"start":32,"end":35,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":5},"identifierName":"foo"},
"name": "foo"
},
"right": {
"type": "NumericLiteral",
"start":38,"end":41,"loc":{"start":{"line":3,"column":8},"end":{"line":3,"column":11}},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
}
},
"extra": {
"shorthand": true
}
}
]
}
}
],
"kind": "const"
}
],
"directives": []
}
}

View File

@ -0,0 +1,70 @@
{
"type": "File",
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
"errors": [
"SyntaxError: Invalid shorthand property initializer. (1:5)"
],
"program": {
"type": "Program",
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
"expression": {
"type": "CallExpression",
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
"callee": {
"type": "Identifier",
"start":0,"end":1,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":1},"identifierName":"f"},
"name": "f"
},
"arguments": [
{
"type": "ObjectExpression",
"start":2,"end":9,"loc":{"start":{"line":1,"column":2},"end":{"line":1,"column":9}},
"properties": [
{
"type": "ObjectProperty",
"start":3,"end":8,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":8}},
"method": false,
"key": {
"type": "Identifier",
"start":3,"end":4,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":4},"identifierName":"x"},
"name": "x"
},
"computed": false,
"shorthand": true,
"value": {
"type": "AssignmentPattern",
"start":3,"end":8,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":8}},
"left": {
"type": "Identifier",
"start":3,"end":4,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":4},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "NumericLiteral",
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8}},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
"extra": {
"shorthand": true
}
}
]
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,69 @@
{
"type": "File",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"errors": [
"SyntaxError: Invalid shorthand property initializer. (1:9)"
],
"program": {
"type": "Program",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"expression": {
"type": "AssignmentExpression",
"start":0,"end":13,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":13}},
"operator": "=",
"left": {
"type": "Identifier",
"start":0,"end":3,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":3},"identifierName":"obj"},
"name": "obj"
},
"right": {
"type": "ObjectExpression",
"start":6,"end":13,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":13}},
"properties": [
{
"type": "ObjectProperty",
"start":7,"end":12,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":12}},
"method": false,
"key": {
"type": "Identifier",
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
"name": "x"
},
"computed": false,
"shorthand": true,
"value": {
"type": "AssignmentPattern",
"start":7,"end":12,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":12}},
"left": {
"type": "Identifier",
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "NumericLiteral",
"start":11,"end":12,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":12}},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
"extra": {
"shorthand": true
}
}
]
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,102 @@
{
"type": "File",
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":2}},
"errors": [
"SyntaxError: Invalid shorthand property initializer. (2:6)"
],
"program": {
"type": "Program",
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":2}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "VariableDeclaration",
"start":0,"end":44,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":2}},
"declarations": [
{
"type": "VariableDeclarator",
"start":6,"end":43,"loc":{"start":{"line":1,"column":6},"end":{"line":4,"column":1}},
"id": {
"type": "Identifier",
"start":6,"end":9,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":9},"identifierName":"obj"},
"name": "obj"
},
"init": {
"type": "ObjectExpression",
"start":12,"end":43,"loc":{"start":{"line":1,"column":12},"end":{"line":4,"column":1}},
"properties": [
{
"type": "ObjectProperty",
"start":16,"end":25,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":11}},
"method": false,
"key": {
"type": "Identifier",
"start":16,"end":19,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":5},"identifierName":"foo"},
"name": "foo"
},
"computed": false,
"shorthand": true,
"value": {
"type": "AssignmentPattern",
"start":16,"end":25,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":11}},
"left": {
"type": "Identifier",
"start":16,"end":19,"loc":{"start":{"line":2,"column":2},"end":{"line":2,"column":5},"identifierName":"foo"},
"name": "foo"
},
"right": {
"type": "NumericLiteral",
"start":22,"end":25,"loc":{"start":{"line":2,"column":8},"end":{"line":2,"column":11}},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
}
},
"extra": {
"shorthand": true
}
},
{
"type": "ObjectProperty",
"start":29,"end":41,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":14}},
"method": false,
"key": {
"type": "Identifier",
"start":29,"end":32,"loc":{"start":{"line":3,"column":2},"end":{"line":3,"column":5},"identifierName":"bar"},
"name": "bar"
},
"computed": false,
"shorthand": false,
"value": {
"type": "AssignmentExpression",
"start":34,"end":41,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":14}},
"operator": "=",
"left": {
"type": "Identifier",
"start":34,"end":35,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":8},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "NumericLiteral",
"start":38,"end":41,"loc":{"start":{"line":3,"column":11},"end":{"line":3,"column":14}},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
}
}
}
]
}
}
],
"kind": "const"
}
],
"directives": []
}
}

View File

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

View File

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

View File

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

View File

@ -0,0 +1,70 @@
{
"type": "File",
"start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}},
"errors": [
"SyntaxError: Invalid shorthand property initializer. (1:14)"
],
"program": {
"type": "Program",
"start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":21,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":21}},
"expression": {
"type": "CallExpression",
"start":0,"end":20,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":20}},
"callee": {
"type": "Identifier",
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5},"identifierName":"async"},
"name": "async"
},
"arguments": [
{
"type": "ObjectExpression",
"start":6,"end":19,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":19}},
"properties": [
{
"type": "ObjectProperty",
"start":8,"end":17,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":17}},
"method": false,
"key": {
"type": "Identifier",
"start":8,"end":13,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":13},"identifierName":"foo33"},
"name": "foo33"
},
"computed": false,
"shorthand": true,
"value": {
"type": "AssignmentPattern",
"start":8,"end":17,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":17}},
"left": {
"type": "Identifier",
"start":8,"end":13,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":13},"identifierName":"foo33"},
"name": "foo33"
},
"right": {
"type": "NumericLiteral",
"start":16,"end":17,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":17}},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
},
"extra": {
"shorthand": true
}
}
]
}
]
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,67 @@
{
"type": "File",
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
"errors": [
"SyntaxError: Invalid shorthand property initializer. (1:20)"
],
"program": {
"type": "Program",
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "VariableDeclaration",
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
"declarations": [
{
"type": "VariableDeclarator",
"start":6,"end":28,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":28}},
"id": {
"type": "Identifier",
"start":6,"end":9,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":9},"identifierName":"foo"},
"name": "foo"
},
"init": {
"type": "ObjectExpression",
"start":12,"end":28,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":28}},
"properties": [
{
"type": "ObjectProperty",
"start":14,"end":26,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":26}},
"method": false,
"key": {
"type": "Identifier",
"start":14,"end":19,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":19},"identifierName":"async"},
"name": "async"
},
"computed": false,
"shorthand": true,
"value": {
"type": "AssignmentPattern",
"start":14,"end":26,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":26}},
"left": {
"type": "Identifier",
"start":14,"end":19,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":19},"identifierName":"async"},
"name": "async"
},
"right": {
"type": "BooleanLiteral",
"start":22,"end":26,"loc":{"start":{"line":1,"column":22},"end":{"line":1,"column":26}},
"value": true
}
},
"extra": {
"shorthand": true
}
}
]
}
}
],
"kind": "const"
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,71 @@
{
"type": "File",
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}},
"errors": [
"SyntaxError: Invalid shorthand property initializer. (1:21)"
],
"program": {
"type": "Program",
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "VariableDeclaration",
"start":0,"end":31,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":31}},
"declarations": [
{
"type": "VariableDeclarator",
"start":6,"end":30,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":30}},
"id": {
"type": "Identifier",
"start":6,"end":9,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":9},"identifierName":"foo"},
"name": "foo"
},
"init": {
"type": "ObjectExpression",
"start":13,"end":29,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":29}},
"properties": [
{
"type": "ObjectProperty",
"start":15,"end":27,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":27}},
"method": false,
"key": {
"type": "Identifier",
"start":15,"end":20,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":20},"identifierName":"async"},
"name": "async"
},
"computed": false,
"shorthand": true,
"value": {
"type": "AssignmentPattern",
"start":15,"end":27,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":27}},
"left": {
"type": "Identifier",
"start":15,"end":20,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":20},"identifierName":"async"},
"name": "async"
},
"right": {
"type": "BooleanLiteral",
"start":23,"end":27,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":27}},
"value": true
}
},
"extra": {
"shorthand": true
}
}
],
"extra": {
"parenthesized": true,
"parenStart": 12
}
}
}
],
"kind": "const"
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,175 @@
{
"type": "File",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"errors": [
"SyntaxError: Invalid shorthand property initializer. (1:22)"
],
"program": {
"type": "Program",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"expression": {
"type": "ArrayExpression",
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},
"elements": [
{
"type": "ArrayExpression",
"start":1,"end":44,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":44}},
"elements": [
{
"type": "ArrayExpression",
"start":2,"end":43,"loc":{"start":{"line":1,"column":2},"end":{"line":1,"column":43}},
"elements": [
{
"type": "ArrayExpression",
"start":3,"end":42,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":42}},
"elements": [
{
"type": "ArrayExpression",
"start":4,"end":41,"loc":{"start":{"line":1,"column":4},"end":{"line":1,"column":41}},
"elements": [
{
"type": "ArrayExpression",
"start":5,"end":40,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":40}},
"elements": [
{
"type": "ArrayExpression",
"start":6,"end":39,"loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":39}},
"elements": [
{
"type": "ArrayExpression",
"start":7,"end":38,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":38}},
"elements": [
{
"type": "ArrayExpression",
"start":8,"end":37,"loc":{"start":{"line":1,"column":8},"end":{"line":1,"column":37}},
"elements": [
{
"type": "ArrayExpression",
"start":9,"end":36,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":36}},
"elements": [
{
"type": "ArrayExpression",
"start":10,"end":35,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":35}},
"elements": [
{
"type": "ArrayExpression",
"start":11,"end":34,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":34}},
"elements": [
{
"type": "ArrayExpression",
"start":12,"end":33,"loc":{"start":{"line":1,"column":12},"end":{"line":1,"column":33}},
"elements": [
{
"type": "ArrayExpression",
"start":13,"end":32,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":32}},
"elements": [
{
"type": "ArrayExpression",
"start":14,"end":31,"loc":{"start":{"line":1,"column":14},"end":{"line":1,"column":31}},
"elements": [
{
"type": "ArrayExpression",
"start":15,"end":30,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":30}},
"elements": [
{
"type": "ArrayExpression",
"start":16,"end":29,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":29}},
"elements": [
{
"type": "ArrayExpression",
"start":17,"end":28,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":28}},
"elements": [
{
"type": "ArrayExpression",
"start":18,"end":27,"loc":{"start":{"line":1,"column":18},"end":{"line":1,"column":27}},
"elements": [
{
"type": "ArrayExpression",
"start":19,"end":26,"loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":26}},
"elements": [
{
"type": "ObjectExpression",
"start":20,"end":25,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":25}},
"properties": [
{
"type": "ObjectProperty",
"start":21,"end":24,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":24}},
"method": false,
"key": {
"type": "Identifier",
"start":21,"end":22,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":22},"identifierName":"a"},
"name": "a"
},
"computed": false,
"shorthand": true,
"value": {
"type": "AssignmentPattern",
"start":21,"end":24,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":24}},
"left": {
"type": "Identifier",
"start":21,"end":22,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":22},"identifierName":"a"},
"name": "a"
},
"right": {
"type": "Identifier",
"start":23,"end":24,"loc":{"start":{"line":1,"column":23},"end":{"line":1,"column":24},"identifierName":"b"},
"name": "b"
}
},
"extra": {
"shorthand": true
}
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"plugins": [["recordAndTuple", { "syntaxType": "hash" }]]
}

View File

@ -0,0 +1,59 @@
{
"type": "File",
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
"errors": [
"SyntaxError: Invalid shorthand property initializer. (1:5)"
],
"program": {
"type": "Program",
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
"sourceType": "script",
"interpreter": null,
"body": [
{
"type": "ExpressionStatement",
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
"expression": {
"type": "RecordExpression",
"start":0,"end":10,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":10}},
"properties": [
{
"type": "ObjectProperty",
"start":3,"end":8,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":8}},
"method": false,
"key": {
"type": "Identifier",
"start":3,"end":4,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":4},"identifierName":"x"},
"name": "x"
},
"computed": false,
"shorthand": true,
"value": {
"type": "AssignmentPattern",
"start":5,"end":8,"loc":{"start":{"line":1,"column":5},"end":{"line":1,"column":8}},
"left": {
"type": "Identifier",
"start":3,"end":4,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":4},"identifierName":"x"},
"name": "x"
},
"right": {
"type": "NumericLiteral",
"start":7,"end":8,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":8}},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
},
"extra": {
"shorthand": true
}
}
]
}
}
],
"directives": []
}
}