diff --git a/hphp/compiler/analysis/emitter.cpp b/hphp/compiler/analysis/emitter.cpp index ba26abf2f..bd36c9620 100644 --- a/hphp/compiler/analysis/emitter.cpp +++ b/hphp/compiler/analysis/emitter.cpp @@ -5319,15 +5319,17 @@ void EmitterVisitor::emitPostponedMeths() { m_curFunc = fe; - if (fe->isClosureBody()) { + if (fe->isClosureBody() || fe->isGeneratorFromClosure()) { // We are going to keep the closure as the first local fe->allocVarId(StringData::GetStaticString("0Closure")); - ClosureUseVarVec* useVars = p.m_closureUseVars; - for (auto& useVar : *useVars) { - // These are all locals. I want them right after the params so I don't - // have to keep track of which one goes where at runtime. - fe->allocVarId(useVar.first); + if (fe->isClosureBody()) { + ClosureUseVarVec* useVars = p.m_closureUseVars; + for (auto& useVar : *useVars) { + // These are all locals. I want them right after the params so I don't + // have to keep track of which one goes where at runtime. + fe->allocVarId(useVar.first); + } } } diff --git a/hphp/compiler/statement/method_statement.cpp b/hphp/compiler/statement/method_statement.cpp index b3acb31e0..8510fe7ec 100644 --- a/hphp/compiler/statement/method_statement.cpp +++ b/hphp/compiler/statement/method_statement.cpp @@ -14,8 +14,6 @@ +----------------------------------------------------------------------+ */ -#include "hphp/runtime/base/complex_types.h" - #include "hphp/compiler/statement/method_statement.h" #include "hphp/compiler/statement/return_statement.h" #include "hphp/compiler/statement/statement_list.h" @@ -47,6 +45,8 @@ #include "hphp/compiler/builtin_symbols.h" #include "hphp/compiler/analysis/alias_manager.h" +#include "hphp/runtime/base/complex_types.h" + #include "hphp/util/parser/parser.h" #include "hphp/util/util.h" @@ -389,8 +389,7 @@ void MethodStatement::analyzeProgram(AnalysisResultPtr ar) { if (ExpressionListPtr params = orig->getParams()) { for (int i = 0; i < params->getCount(); ++i) { auto param = dynamic_pointer_cast((*params)[i]); - Symbol *gp = variables->addDeclaredSymbol( - param->getName(), ConstructPtr()); + Symbol *gp = variables->addDeclaredSymbol(param->getName(), param); gp->setGeneratorParameter(); if (param->isRef()) { gp->setRefGeneratorParameter();