зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1096378 - Disallow duplicated parameter in method definition. r=jorendorff
This commit is contained in:
Родитель
09771b2a17
Коммит
3a46343337
|
@ -1624,7 +1624,7 @@ Parser<ParseHandler>::functionArguments(FunctionSyntaxKind kind, FunctionType ty
|
||||||
bool hasDefaults = false;
|
bool hasDefaults = false;
|
||||||
Node duplicatedArg = null();
|
Node duplicatedArg = null();
|
||||||
Node list = null();
|
Node list = null();
|
||||||
bool disallowDuplicateArgs = kind == Arrow;
|
bool disallowDuplicateArgs = kind == Arrow || kind == Method;
|
||||||
|
|
||||||
if (type == Getter) {
|
if (type == Getter) {
|
||||||
report(ParseError, false, null(), JSMSG_ACCESSOR_WRONG_ARGS, "getter", "no", "s");
|
report(ParseError, false, null(), JSMSG_ACCESSOR_WRONG_ARGS, "getter", "no", "s");
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
// Make sure duplicated name is allowed in non-strict.
|
||||||
|
function f0(a) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// SyntaxError should be thrown if method definition has duplicated name.
|
||||||
|
assertThrowsInstanceOf(() => eval(`
|
||||||
|
({
|
||||||
|
m1(a, a) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
`), SyntaxError);
|
||||||
|
assertThrowsInstanceOf(() => eval(`
|
||||||
|
({
|
||||||
|
m2(a, ...a) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
`), SyntaxError);
|
||||||
|
|
||||||
|
reportCompare(0, 0, 'ok');
|
Загрузка…
Ссылка в новой задаче