Bug #72692 [Opn]: Bad behaviour of AppendIterator with Empty Generator
| From: | nikic@php.net | Date: | Thu, 28 Jul 2016 23:59:57 +0000 |
| Subject: | Bug #72692 [Opn]: Bad behaviour of AppendIterator with Empty Generator | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202692@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72692&edit=1
ID: 72692
Updated by: nikic@php.net
Reported by: pierrick@php.net
Summary: Bad behaviour of AppendIterator with Empty Generator
Status: Open
Type: Bug
Package: SPL related
PHP Version: 5.6.24
Block user comment: N
Private report: N
New Comment:
Related: Bug #71436
Previous Comments:
------------------------------------------------------------------------
[2016-07-28 05:09:13] pierrick@php.net
Description:
------------
When giving an new empty generator, AppendIterator will directly throw an Exception "Cannot
traverse an already closed generator" even if the given generator is new.
Test script:
---------------
<?php
function createEmptyGen() { if(false) { yield 1; } }
$gen = createEmptyGen();
$ai = new AppendIterator();
$ai->append($gen);
var_dump(iterator_to_array($gen));
Expected result:
----------------
array(0) {
}
Actual result:
--------------
Fatal error: Uncaught Exception: Cannot traverse an already closed generator in
/home/pierrick/php-src/github/foo.php:14
Stack trace:
#0 /home/pierrick/php-src/github/foo.php(14): iterator_to_array(Object(Generator))
#1 {main}
thrown in /home/pierrick/php-src/github/foo.php on line 14
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72692&edit=1