1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/Zend/tests/bug62991.phpt
2012-09-05 09:50:55 +04:00

51 lines
787 B
PHP

--TEST--
Bug #62991 (Segfault with generator and closure)
--FILE--
<?php
function test( array $array )
{
$closure = function() use ( $array ) {
print_r( $array );
yield "hi";
};
return $closure();
}
function test2( array $array )
{
$closure = function() use ( $array ) {
print_r( $array );
yield "hi";
};
return $closure; // if you return the $closure and call it outside this function it works.
}
$generator = test(array( 1, 2, 3 ) );
foreach($generator as $something) {
}
$generator = test2(array( 1, 2, 3 ) );
foreach($generator() as $something) {
}
$generator = test2(array( 1, 2, 3 ) );
echo "okey\n";
?>
--EXPECT--
Array
(
[0] => 1
[1] => 2
[2] => 3
)
Array
(
[0] => 1
[1] => 2
[2] => 3
)
okey