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

Commit

Permalink
Temporary rollback for erroring on trailing comma with spread (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
hzoo authored Oct 2, 2016
1 parent 1285131 commit 5bac6e8
Show file tree
Hide file tree
Showing 3 changed files with 246 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/parser/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,9 @@ pp.parseObj = function (isPattern, refShorthandDefaultPos) {
} else if (this.eat(tt.braceR)) {
break;
} else if (this.match(tt.comma) && this.lookahead().type === tt.braceR) {
this.unexpected(position, "A trailing comma is not permitted after the rest element");
// TODO: temporary rollback
// this.unexpected(position, "A trailing comma is not permitted after the rest element");
continue;
} else {
firstRestLocation = position;
continue;
Expand Down
243 changes: 243 additions & 0 deletions test/fixtures/experimental/object-rest-spread/8/expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
{
"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",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 26
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 25
}
},
"id": {
"type": "ObjectPattern",
"start": 4,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 19
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "x"
},
"name": "x"
},
"value": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "x"
},
"name": "x"
},
"extra": {
"shorthand": true
}
},
{
"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": "y"
},
"name": "y"
},
"value": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "y"
},
"name": "y"
},
"extra": {
"shorthand": true
}
},
{
"type": "RestProperty",
"start": 12,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 16
}
},
"argument": {
"type": "Identifier",
"start": 15,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 16
},
"identifierName": "z"
},
"name": "z"
}
}
]
},
"init": {
"type": "Identifier",
"start": 22,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 25
},
"identifierName": "obj"
},
"name": "obj"
}
}
],
"kind": "let"
}
],
"directives": []
}
}
3 changes: 0 additions & 3 deletions test/fixtures/experimental/object-rest-spread/8/options.json

This file was deleted.

0 comments on commit 5bac6e8

Please sign in to comment.