Bug #72518 [NEW]: iterator_to_array() misses values from generator using yield from

From: Date: Wed, 29 Jun 2016 20:36:34 +0000
Subject: Bug #72518 [NEW]: iterator_to_array() misses values from generator using yield from
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201922@lists.php.net to get a copy of this message
From: trowski Operating system: OS X PHP version: 7.0.8 Package: SPL related Bug Type: Bug Bug description:iterator_to_array() misses values from generator using yield from Description: ------------ iterator_to_array() does not add all values yielded from a generator if yield from is used in the generator. Test script: --------------- <?php function gen1() { yield 1; yield from gen2(); yield 5; } function gen2() { yield 2; yield 3; yield 4; } print_r(iterator_to_array(gen1(), true)); $result = []; foreach (gen1() as $yielded) { $result[] = $yielded; } print_r($result); Expected result: ---------------- Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) Actual result: -------------- Array ( [0] => 2 [1] => 5 [2] => 4 ) Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) -- Edit bug report at https://bugs.php.net/bug.php?id=72518&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72518&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72518&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72518&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72518&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72518&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72518&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72518&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72518&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72518&r=support Expected behavior: https://bugs.php.net/fix.php?id=72518&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72518&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72518&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72518&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72518&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72518&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72518&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72518&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72518&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72518&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72518&r=mysqlcfg

« previous php.bugs (#201922) next »