add support for trailing commas in arrow function parameter lists - fixes #1841
This commit is contained in:
@@ -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 }
|
||||
});
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
(x, y, ) => {};
|
||||
@@ -0,0 +1 @@
|
||||
(function (x, y) {});
|
||||
Reference in New Issue
Block a user