mirror of
https://github.com/classilla/tenfourfox.git
synced 2025-02-09 07:32:04 +00:00
Bug 1243793 - Fix handling of labels when emitting hoisted function definitions. (r=jorendorff)
This commit is contained in:
parent
8a51cc1f91
commit
c0ffd70f92
@ -5377,15 +5377,17 @@ BytecodeEmitter::emitHoistedFunctionsInList(ParseNode* list)
|
||||
MOZ_ASSERT(list->pn_xflags & PNX_FUNCDEFS);
|
||||
|
||||
for (ParseNode* pn = list->pn_head; pn; pn = pn->pn_next) {
|
||||
ParseNode* maybeFun = pn;
|
||||
|
||||
if (!sc->strict()) {
|
||||
while (pn->isKind(PNK_LABEL))
|
||||
pn = pn->as<LabeledStatement>().statement();
|
||||
while (maybeFun->isKind(PNK_LABEL))
|
||||
maybeFun = maybeFun->as<LabeledStatement>().statement();
|
||||
}
|
||||
|
||||
if (pn->isKind(PNK_ANNEXB_FUNCTION) ||
|
||||
(pn->isKind(PNK_FUNCTION) && pn->functionIsHoisted()))
|
||||
if (maybeFun->isKind(PNK_ANNEXB_FUNCTION) ||
|
||||
(maybeFun->isKind(PNK_FUNCTION) && maybeFun->functionIsHoisted()))
|
||||
{
|
||||
if (!emitTree(pn))
|
||||
if (!emitTree(maybeFun))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,18 @@
|
||||
// Annex B still works.
|
||||
assertEq(f(), 4);
|
||||
|
||||
// The same thing with labels.
|
||||
{
|
||||
assertEq(f(), 4);
|
||||
function f() { return 3; }
|
||||
assertEq(f(), 4);
|
||||
l: function f() { return 4; }
|
||||
assertEq(f(), 4);
|
||||
}
|
||||
|
||||
// Annex B still works.
|
||||
assertEq(f(), 4);
|
||||
|
||||
function test() {
|
||||
{
|
||||
assertEq(f(), 2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user