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:
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user