Bug #77433 [NEW]: iterator_to_array incorrect result when using yield from
| From: | jwurtz at jolicode dot com | Date: | Wed, 09 Jan 2019 14:00:31 +0000 |
| Subject: | Bug #77433 [NEW]: iterator_to_array incorrect result when using yield from | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-218860@lists.php.net to get a copy of this message | ||
From: jwurtz at jolicode dot com
Operating system:
PHP version: 7.1.25
Package: Arrays related
Bug Type: Bug
Bug description:iterator_to_array incorrect result when using yield from
Description:
------------
When using iterator_to_array on a function that return a \Generator, if
this function use both yield and yield from it will only put values of
the yield from expression.
Test script:
---------------
<?php
function yield1() {
yield 'foo';
}
function yield2() {
yield 'bar';
yield from yield1();
}
// Will only display foo
var_dump(iterator_to_array(yield2()));
// will correctly display each value
foreach (yield2() as $data) {
var_dump($data);
}
Expected result:
----------------
It should create an array with all values and not only the one from the
yield from expression.
Actual result:
--------------
Create an array only on the yield from expression
--
Edit bug report at https://bugs.php.net/bug.php?id=77433&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77433&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77433&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77433&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77433&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77433&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77433&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77433&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77433&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77433&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77433&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77433&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77433&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77433&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77433&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77433&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77433&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77433&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77433&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77433&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77433&r=mysqlcfg