mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
Bug 1096377 - Disallow duplicated parameter in arrow functions. r=jorendorff
This commit is contained in:
parent
8ecef5dcb4
commit
7786487bbe
@ -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");
|
||||
|
15
js/src/tests/ecma_6/Function/arrow-has-duplicated.js
Normal file
15
js/src/tests/ecma_6/Function/arrow-has-duplicated.js
Normal 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');
|
Loading…
Reference in New Issue
Block a user