Bug #79616 [Opn->Dup]: Wrong behavior of Generator close when nesting "yield from"
| From: | nikic@php.net | Date: | Thu, 21 May 2020 10:37:52 +0000 |
| Subject: | Bug #79616 [Opn->Dup]: Wrong behavior of Generator close when nesting "yield from" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227112@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79616&edit=1
ID: 79616
Updated by: nikic@php.net
Reported by: jeremy at derusse dot com
Summary: Wrong behavior of Generator close when nesting
"yield from"
-Status: Open
+Status: Duplicate
Type: Bug
Package: Unknown/Other Function
Operating System: Linux
PHP Version: 7.4.6
Block user comment: N
Private report: N
New Comment:
Duplicate of bug #79600.
Previous Comments:
------------------------------------------------------------------------
[2020-05-21 10:33:25] jeremy at derusse dot com
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 this bug report at https://bugs.php.net/bug.php?id=79616&edit=1