|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79614 Nested 'yield from' duplicate first element
Submitted: 2020-05-20 02:22 UTC Modified: 2020-05-20 22:28 UTC
From: ponomarev at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Scripting Engine problem
PHP Version: 7.4.6 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ponomarev at gmail dot com
New email:
PHP Version: OS:


 [2020-05-20 02:22 UTC] ponomarev at gmail dot com
See the example script. 

First element yielded twice if iterate over a generator that `yield from` another generator.

Test script:


$arr = [1,2,3];

function a($x){
    yield from $x;

foreach(a(a($arr)) as $x){

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-05-20 02:42 UTC]
No doubt related to bug #78434.
 [2020-05-20 07:17 UTC]
-Status: Open +Status: Duplicate -Package: *General Issues +Package: Scripting Engine problem -Assigned To: +Assigned To: cmb
 [2020-05-20 07:17 UTC]
Well, actually a duplicate of that bug.
 [2020-05-20 18:11 UTC]
Duplicate? 78434 fixed an issue where the first generated item wasn't being yielded. This is an issue where the first generated item is being yielded too many times - and it started after 78434's fix landed in 7.4.6.
 [2020-05-20 18:25 UTC] ponomarev at gmail dot com
It seems to be duplicate of #79600
 [2020-05-20 18:26 UTC]
Well spotted. The fix for bug #79600 will be in 7.4.7.
 [2020-05-20 22:28 UTC]
Thanks for the correction! :)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 17 11:01:28 2024 UTC