Bug #79616 [NEW]: Wrong behavior of Generator close when nesting "yield from"
| From: | jeremy at derusse dot com | Date: | Thu, 21 May 2020 10:33:25 +0000 |
| Subject: | Bug #79616 [NEW]: Wrong behavior of Generator close when nesting "yield from" | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-227111@lists.php.net to get a copy of this message | ||
From: jeremy at derusse dot com
Operating system: Linux
PHP version: 7.4.6
Package: Unknown/Other Function
Bug Type: Bug
Bug description:Wrong behavior of Generator close when nesting "yield from"
Description:
------------
Since php 7.4.6, When nesting several
yield from, the
\Generator::valid methods return true while the Generator stay open
after the last item. (calling Generator::valid return once true after
the last item.
Test script:
---------------
<?php
function foo()
{
yield from ['foo', 'bar'];
}
function bar()
{
yield from foo();
}
function countGenerator($generator)
{
for ($count = 0; $generator->valid(); $generator->next()) {
++$count;
}
return $count;
}
var_dump(countGenerator(foo()));
var_dump(countGenerator(bar()));
Expected result:
----------------
int(2)
int(2)
Actual result:
--------------
int(2)
int(3)
--
Edit bug report at https://bugs.php.net/bug.php?id=79616&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79616&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79616&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79616&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79616&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79616&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79616&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79616&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79616&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79616&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79616&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79616&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79616&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79616&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79616&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79616&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79616&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79616&r=mysqlcfg