diff options
| author | Dmitry Stogov <dmitry@zend.com> | 2012-09-05 09:50:55 +0400 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@zend.com> | 2012-09-05 09:50:55 +0400 |
| commit | 72473962a9722ee0a8107909f32c145d3b44f906 (patch) | |
| tree | f8f2148413b12f046652b31fa5493a3788581191 /Zend/tests/bug62991.phpt | |
| parent | 2a57a256369e568a607159dbd4bb8bd8474df281 (diff) | |
| download | php-git-72473962a9722ee0a8107909f32c145d3b44f906.tar.gz | |
Fixed bug #62991 (Segfault with generator and closure)
Diffstat (limited to 'Zend/tests/bug62991.phpt')
| -rw-r--r-- | Zend/tests/bug62991.phpt | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Zend/tests/bug62991.phpt b/Zend/tests/bug62991.phpt new file mode 100644 index 0000000000..cb4ff93359 --- /dev/null +++ b/Zend/tests/bug62991.phpt @@ -0,0 +1,50 @@ +--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 |
