From 7f918147ce8b9c831570ad0421240d7d97b97bd3 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Sat, 1 Oct 2016 19:57:12 -0400 Subject: [PATCH] Temporary rollback for erroring on trailing comma with spread --- src/parser/expression.js | 4 +- .../object-rest-spread/8/expected.json | 243 ++++++++++++++++++ .../object-rest-spread/8/options.json | 3 - 3 files changed, 246 insertions(+), 4 deletions(-) create mode 100644 test/fixtures/experimental/object-rest-spread/8/expected.json delete mode 100644 test/fixtures/experimental/object-rest-spread/8/options.json diff --git a/src/parser/expression.js b/src/parser/expression.js index f8a50c7d84..1e503bea18 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -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; diff --git a/test/fixtures/experimental/object-rest-spread/8/expected.json b/test/fixtures/experimental/object-rest-spread/8/expected.json new file mode 100644 index 0000000000..f97a0ab95c --- /dev/null +++ b/test/fixtures/experimental/object-rest-spread/8/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/experimental/object-rest-spread/8/options.json b/test/fixtures/experimental/object-rest-spread/8/options.json deleted file mode 100644 index 4a97ac85ea..0000000000 --- a/test/fixtures/experimental/object-rest-spread/8/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "A trailing comma is not permitted after the rest element (1:16)" -}