Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
Fix #304 and #309
Browse files Browse the repository at this point in the history
  • Loading branch information
danez committed Jan 31, 2017
1 parent 898c4a7 commit e907da6
Show file tree
Hide file tree
Showing 5 changed files with 525 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/parser/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,9 @@ pp.parseObj = function (isPattern, refShorthandDefaultPos) {
}

if (this.hasPlugin("objectRestSpread") && this.match(tt.ellipsis)) {
prop = this.parseSpread();
prop = this.parseSpread(isPattern ? { start: 0 } : undefined);
prop.type = isPattern ? "RestProperty" : "SpreadProperty";
if (isPattern) this.toAssignable(prop.argument, true, "object pattern");
node.properties.push(prop);
if (isPattern) {
const position = this.state.start;
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/experimental/object-rest-spread/16/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var {...{z}} = { z: 1};
243 changes: 243 additions & 0 deletions test/fixtures/experimental/object-rest-spread/16/expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
{
"type": "File",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"program": {
"type": "Program",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 22
}
},
"id": {
"type": "ObjectPattern",
"start": 4,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 12
}
},
"properties": [
{
"type": "RestProperty",
"start": 5,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 11
}
},
"argument": {
"type": "ObjectPattern",
"start": 8,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 11
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "z"
},
"name": "z"
},
"value": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "z"
},
"name": "z"
},
"extra": {
"shorthand": true
}
}
]
}
}
]
},
"init": {
"type": "ObjectExpression",
"start": 15,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 22
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 17,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 21
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 17,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 18
},
"identifierName": "z"
},
"name": "z"
},
"value": {
"type": "NumericLiteral",
"start": 20,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 21
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
]
}
}
],
"kind": "var"
}
],
"directives": []
}
}
1 change: 1 addition & 0 deletions test/fixtures/experimental/object-rest-spread/17/actual.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var { ...{ x = 5 } } = {x : 1};
Loading

0 comments on commit e907da6

Please sign in to comment.