fix static closures

I added the check for this in the interpreter but ##f_array_map## re-enteres the VM via a different path than FCall. Here is the equivilent check for the VM.
Esse commit está contido em:
ptarjan
2013-03-20 19:39:55 -07:00
commit de Sara Golemon
commit a6d70040fa
4 arquivos alterados com 36 adições e 2 exclusões
+2 -1
Ver Arquivo
@@ -344,7 +344,8 @@ vm_decode_function(CVarRef function,
this_ = function.asCObjRef().get();
cls = nullptr;
const HPHP::VM::Func *f = this_->getVMClass()->lookupMethod(invokeStr);
if (f != nullptr && (f->attrs() & HPHP::VM::AttrStatic)) {
if (f != nullptr &&
((f->attrs() & HPHP::VM::AttrStatic) && !f->isClosureBody())) {
// If __invoke is static, invoke it as such
cls = this_->getVMClass();
this_ = nullptr;
+2 -1
Ver Arquivo
@@ -2071,7 +2071,8 @@ void VMExecutionContext::invokeFunc(TypedValue* retval,
// If this is a method, either this_ or cls must be non-NULL
assert(!f->preClass() || (this_ || cls));
// If this is a static method, this_ must be NULL
assert(!(f->attrs() & HPHP::VM::AttrStatic) || (!this_));
assert(!(f->attrs() & HPHP::VM::AttrStatic && !f->isClosureBody()) ||
(!this_));
// invName should only be non-NULL if we are calling __call or
// __callStatic
assert(!invName || f->name()->isame(s___call.get()) ||
+8
Ver Arquivo
@@ -26,7 +26,15 @@ class A {
};
$a();
}
static function d() {
var_dump(array_map(function($a) { return $a; }, array(1,2,3)));
}
}
(new A)->b();
A::b();
(new A)->c();
A::c();
(new A)->d();
A::d();
+24
Ver Arquivo
@@ -4,7 +4,31 @@ object(A)#1 (1) {
}
HipHop Notice: Undefined variable: this in hphp/test/vm/closure_static.php on line 13
NULL
HipHop Notice: Undefined variable: this in hphp/test/vm/closure_static.php on line 8
NULL
HipHop Notice: Undefined variable: this in hphp/test/vm/closure_static.php on line 13
NULL
HipHop Notice: Undefined variable: this in hphp/test/vm/closure_static.php on line 20
NULL
HipHop Notice: Undefined variable: this in hphp/test/vm/closure_static.php on line 25
NULL
HipHop Notice: Undefined variable: this in hphp/test/vm/closure_static.php on line 20
NULL
HipHop Notice: Undefined variable: this in hphp/test/vm/closure_static.php on line 25
NULL
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}