php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ponomarev at gmail dot com
New email:
PHP Version: OS:

 

 [2020-05-20 02:22 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-05-20 02:42 UTC] requinix@php.net
No doubt related to bug #78434.
 [2020-05-20 07:17 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Package: *General Issues +Package: Scripting Engine problem -Assigned To: +Assigned To: cmb
 [2020-05-20 07:17 UTC] cmb@php.net
Well, actually a duplicate of that bug.
 [2020-05-20 18:11 UTC] requinix@php.net
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] requinix@php.net
Well spotted. The fix for bug #79600 will be in 7.4.7.
 [2020-05-20 22:28 UTC] cmb@php.net
Thanks for the correction! :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 02:01:30 2024 UTC