Bug 1096377 - Disallow duplicated parameter in arrow functions. r=jorendorff

This commit is contained in:
Tooru Fujisawa 2015-02-03 14:59:32 +09:00
parent 8ecef5dcb4
commit 7786487bbe
2 changed files with 16 additions and 1 deletions

View File

@ -1624,7 +1624,7 @@ Parser<ParseHandler>::functionArguments(FunctionSyntaxKind kind, FunctionType ty
bool hasDefaults = false;
Node duplicatedArg = null();
Node list = null();
bool disallowDuplicateArgs = false;
bool disallowDuplicateArgs = kind == Arrow;
if (type == Getter) {
report(ParseError, false, null(), JSMSG_ACCESSOR_WRONG_ARGS, "getter", "no", "s");

View File

@ -0,0 +1,15 @@
// Make sure duplicated name is allowed in non-strict.
function f0(a, a) {
}
// SyntaxError should be thrown if arrow function has duplicated name.
assertThrowsInstanceOf(() => eval(`
(a, a) => {
};
`), SyntaxError);
assertThrowsInstanceOf(() => eval(`
(a, ...a) => {
};
`), SyntaxError);
reportCompare(0, 0, 'ok');