diff --git a/hphp/runtime/vm/jit/hhbctranslator.cpp b/hphp/runtime/vm/jit/hhbctranslator.cpp index 7d7131073..75f56e296 100644 --- a/hphp/runtime/vm/jit/hhbctranslator.cpp +++ b/hphp/runtime/vm/jit/hhbctranslator.cpp @@ -1026,7 +1026,7 @@ void HhbcTranslator::emitCreateCont(bool getArgs, mapContParams(params, origFunc, genFunc)) { static auto const thisStr = StringData::GetStaticString("this"); Id thisId = kInvalidId; - const bool fillThis = origFunc->isNonClosureMethod() && + const bool fillThis = origFunc->isMethod() && !origFunc->isStatic() && ((thisId = genFunc->lookupVarId(thisStr)) != kInvalidId) && (origFunc->lookupVarId(thisStr) == kInvalidId); diff --git a/hphp/test/slow/yield/closure_gen_with_this_loc.php b/hphp/test/slow/yield/closure_gen_with_this_loc.php new file mode 100644 index 000000000..f657062ee --- /dev/null +++ b/hphp/test/slow/yield/closure_gen_with_this_loc.php @@ -0,0 +1,21 @@ +gen(function($x) { var_dump(get_class($x)); }); + foreach ($f() as $e) { + var_dump($e); + } +} + +test(); + +function fiz($x) { return false; } diff --git a/hphp/test/slow/yield/closure_gen_with_this_loc.php.expect b/hphp/test/slow/yield/closure_gen_with_this_loc.php.expect new file mode 100644 index 000000000..d05e649ff --- /dev/null +++ b/hphp/test/slow/yield/closure_gen_with_this_loc.php.expect @@ -0,0 +1,2 @@ +string(1) "X" +NULL