зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1317374 - Don't do Annex B lexical function behavior when redeclaring a parameter name. (r=Waldo)
This commit is contained in:
Родитель
5262f0e0a9
Коммит
28b9daf168
|
@ -1177,6 +1177,12 @@ Parser<ParseHandler>::tryDeclareVar(HandlePropertyName name, DeclarationKind kin
|
|||
*redeclaredKind = Some(declaredKind);
|
||||
return true;
|
||||
}
|
||||
} else if (kind == DeclarationKind::VarForAnnexBLexicalFunction) {
|
||||
MOZ_ASSERT(DeclarationKindIsParameter(declaredKind));
|
||||
|
||||
// Annex B.3.3.1 disallows redeclaring parameter names.
|
||||
*redeclaredKind = Some(declaredKind);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (!scope->addDeclaredName(pc, p, name, kind))
|
||||
|
|
|
@ -8,9 +8,11 @@ assertEq(typeof f1(true), "function");
|
|||
assertEq(f1(false), 3);
|
||||
|
||||
function f2(b, w) {
|
||||
// Annex B doesn't apply to functions in blocks with the same name as a
|
||||
// parameter.
|
||||
if (b)
|
||||
function w() {}
|
||||
return w;
|
||||
}
|
||||
assertEq(typeof f2(true, 3), "function");
|
||||
assertEq(typeof f2(true, 3), "number");
|
||||
assertEq(f2(false, 3), 3);
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
// Annex B.3.3.1 disallows Annex B lexical function behavior when redeclaring a
|
||||
// parameter.
|
||||
|
||||
(function(f) {
|
||||
if (true) function f() { }
|
||||
assertEq(f, 123);
|
||||
}(123));
|
||||
|
||||
(function(f) {
|
||||
{ function f() { } }
|
||||
assertEq(f, 123);
|
||||
}(123));
|
||||
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
|
@ -20,7 +20,7 @@ function test()
|
|||
printBugNumber(BUGNUMBER);
|
||||
printStatus (summary);
|
||||
|
||||
expect = 'function x() {}';
|
||||
expect = '1';
|
||||
|
||||
function g(x) { if (1) function x() {} return x; }
|
||||
print(actual = g(1) + '');
|
||||
|
|
|
@ -32,7 +32,7 @@ function test()
|
|||
|
||||
var r = f(0);
|
||||
|
||||
if (typeof(r[0]) != "function")
|
||||
if (typeof(r[0]) != "number")
|
||||
actual += "Bad r[0]";
|
||||
|
||||
if (typeof(r[1]) != "function")
|
||||
|
|
Загрузка…
Ссылка в новой задаче