Skip to content

Commit 7f5a86d

Browse files
committed
expand RestElement to support all patterns
This is a followup to estools#236 that brings RestElement into full spec compliance.
1 parent 2e90c2b commit 7f5a86d

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

escodegen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2063,7 +2063,7 @@
20632063
},
20642064

20652065
RestElement: function(expr, precedence, flags) {
2066-
return '...' + generateIdentifier(expr.argument);
2066+
return '...' + this.generatePattern(expr.argument);
20672067
},
20682068

20692069
ClassExpression: function (expr, precedence, flags) {

test/harmony.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,47 @@ data = {
14941494
}
14951495
]
14961496
}
1497+
},
1498+
'[x, ...[y,z]] = list;': {
1499+
"type": "Program",
1500+
"body": [
1501+
{
1502+
"type": "ExpressionStatement",
1503+
"expression": {
1504+
"type": "AssignmentExpression",
1505+
"operator": "=",
1506+
"left": {
1507+
"type": "ArrayPattern",
1508+
"elements": [
1509+
{
1510+
"type": "Identifier",
1511+
"name": "x"
1512+
},
1513+
{
1514+
"type": "RestElement",
1515+
"argument": {
1516+
"type": "ArrayPattern",
1517+
"elements": [
1518+
{
1519+
"type": "Identifier",
1520+
"name": "y"
1521+
},
1522+
{
1523+
"type": "Identifier",
1524+
"name": "z"
1525+
}
1526+
]
1527+
}
1528+
}
1529+
]
1530+
},
1531+
"right": {
1532+
"type": "Identifier",
1533+
"name": "list"
1534+
}
1535+
}
1536+
}
1537+
]
14971538
}
14981539
},
14991540

0 commit comments

Comments
 (0)