зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1231758 - Fix bogus assertion in BCE for Annex B function assignment. (r=jorendorff)
This commit is contained in:
Родитель
8dfc60e1e7
Коммит
ea087bfc50
|
@ -4389,13 +4389,25 @@ BytecodeEmitter::emitVariables(ParseNode* pn, VarEmitOption emitOption)
|
|||
* i' to be hoisted out of the loop.
|
||||
*/
|
||||
MOZ_ASSERT(binding->isOp(JSOP_NOP));
|
||||
MOZ_ASSERT(emitOption != DefineVars && emitOption != AnnexB);
|
||||
MOZ_ASSERT(emitOption != DefineVars);
|
||||
MOZ_ASSERT_IF(emitOption == AnnexB, binding->pn_left->isKind(PNK_NAME));
|
||||
|
||||
/*
|
||||
* To allow the front end to rewrite var f = x; as f = x; when a
|
||||
* function f(){} precedes the var, detect simple name assignment
|
||||
* here and initialize the name.
|
||||
*/
|
||||
// To allow the front end to rewrite |var f = x;| as |f = x;| when a
|
||||
// |function f(){}| precedes the var, detect simple name assignment
|
||||
// here and initialize the name.
|
||||
//
|
||||
// There is a corner case where a function declaration synthesizes
|
||||
// an Annex B declaration, which in turn gets rewritten later as a
|
||||
// simple assignment due to hoisted function declaration of the
|
||||
// same name. For example,
|
||||
//
|
||||
// {
|
||||
// // Synthesizes an Annex B declaration because no 'f' binding
|
||||
// // yet exists. This later gets rewritten as an assignment when
|
||||
// // the outer function 'f' gets hoisted.
|
||||
// function f() {}
|
||||
// }
|
||||
// function f() {}
|
||||
if (binding->pn_left->isKind(PNK_NAME)) {
|
||||
if (!emitSingleVariable(pn, binding->pn_left, binding->pn_right, emitOption))
|
||||
return false;
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
function f() { return "inner"; }
|
||||
}
|
||||
|
||||
function f() { return "outer"; }
|
||||
|
||||
reportCompare(f(), "inner");
|
Загрузка…
Ссылка в новой задаче