add support for trailing commas in arrow function parameter lists - fixes #1841

This commit is contained in:
Sebastian McKenzie
2015-06-26 00:37:33 +01:00
parent 59ed7977ef
commit e4083fbbd7
4 changed files with 62 additions and 2 deletions

View File

@@ -3374,6 +3374,49 @@ test("class Foo { bar(a,) { } }", {
features: { "es7.trailingFunctionCommas": true }
});
test("(x, y, ) => 1;", {
start: 0,
body: [{
start: 0,
expression: {
start: 0,
id: null,
generator: false,
expression: true,
params: [
{
start: 1,
name: "x",
type: "Identifier",
end: 2
},
{
start: 4,
name: "y",
type: "Identifier",
end: 5
}
],
body: {
start: 12,
value: 1,
raw: "1",
type: "Literal",
end: 13
},
type: "ArrowFunctionExpression",
end: 13
},
type: "ExpressionStatement",
end: 14
}],
type: "Program",
end: 14
}, {
ecmaVersion: 7,
features: { "es7.trailingFunctionCommas": true }
});
testFail("log(,);", "Unexpected token (1:4)", {
ecmaVersion: 7,
features: { "es7.trailingFunctionCommas": true }
@@ -3383,3 +3426,8 @@ testFail("function log(,) { }", "Unexpected token (1:13)", {
ecmaVersion: 7,
features: { "es7.trailingFunctionCommas": true }
});
testFail("('foo',)", "Unexpected token (1:7)", {
ecmaVersion: 7,
features: { "es7.trailingFunctionCommas": true }
});

View File

@@ -0,0 +1 @@
(function (x, y) {});