Bug #79614 [Opn]: Nested 'yield from' duplicate first element

From: Date: Wed, 20 May 2020 02:42:47 +0000
Subject: Bug #79614 [Opn]: Nested 'yield from' duplicate first element
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227086@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79614&edit=1 ID: 79614 Updated by: requinix@php.net Reported by: ponomarev at gmail dot com Summary: Nested 'yield from' duplicate first element Status: Open Type: Bug Package: *General Issues PHP Version: 7.4.6 Block user comment: N Private report: N New Comment: No doubt related to bug #78434. Previous Comments: ------------------------------------------------------------------------ [2020-05-20 02:22:18] ponomarev at gmail dot com Description: ------------ See the example script. First element yielded twice if iterate over a generator that yield from another generator. Test script: --------------- https://3v4l.org/2ZQ8d <?php $arr = [1,2,3]; function a($x){ yield from $x; } foreach(a(a($arr)) as $x){ print_r($x); } Expected result: ---------------- 123 Actual result: -------------- 1123 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79614&edit=1

« previous php.bugs (#227086) next »