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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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: Sat Dec 21 16:01:28 2024 UTC