mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1231758 - Fix bogus assertion in BCE for Annex B function assignment. (r=jorendorff)
This commit is contained in:
parent
95fc663831
commit
3a62ab69d0
@ -4389,13 +4389,25 @@ BytecodeEmitter::emitVariables(ParseNode* pn, VarEmitOption emitOption)
|
|||||||
* i' to be hoisted out of the loop.
|
* i' to be hoisted out of the loop.
|
||||||
*/
|
*/
|
||||||
MOZ_ASSERT(binding->isOp(JSOP_NOP));
|
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
|
||||||
* To allow the front end to rewrite var f = x; as f = x; when a
|
// |function f(){}| precedes the var, detect simple name assignment
|
||||||
* function f(){} precedes the var, detect simple name assignment
|
// here and initialize the name.
|
||||||
* 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 (binding->pn_left->isKind(PNK_NAME)) {
|
||||||
if (!emitSingleVariable(pn, binding->pn_left, binding->pn_right, emitOption))
|
if (!emitSingleVariable(pn, binding->pn_left, binding->pn_right, emitOption))
|
||||||
return false;
|
return false;
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
function f() { return "inner"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
function f() { return "outer"; }
|
||||||
|
|
||||||
|
reportCompare(f(), "inner");
|
Loading…
Reference in New Issue
Block a user