1
0
mirror of https://github.com/php/php-src.git synced 2026-04-25 00:48:25 +02:00

Fix bug where return type checking was overzealous and interfered with generators

This commit is contained in:
Anthony Ferrara
2015-02-18 10:59:33 -05:00
parent 9109e48749
commit e2053fa94c
2 changed files with 27 additions and 1 deletions
@@ -0,0 +1,25 @@
--TEST--
Generators can return without values
--FILE--
<?php
function gen() {
yield;
return;
}
function gen2() {
yield;
return null;
}
var_dump(gen());
var_dump(gen2());
?>
--EXPECTF--
object(Generator)#%d (0) {
}
object(Generator)#%d (0) {
}
+2 -1
View File
@@ -3268,7 +3268,8 @@ void zend_compile_return(zend_ast *ast) /* {{{ */
opline->op1.var = CG(context).fast_call_var;
}
if (CG(active_op_array)->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
// Generator return types are handled separately
if (!(CG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) && CG(active_op_array)->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
zend_arg_info *arg_info = CG(active_op_array)->arg_info - 1;
/* for scalar, weak return types, the value may be casted