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

From: Date: Wed, 20 May 2020 18:25:00 +0000
Subject: Bug #79614 [Dup]: Nested 'yield from' duplicate first element
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227105@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
 User updated by:    ponomarev at gmail dot com
 Reported by:        ponomarev at gmail dot com
 Summary:            Nested 'yield from' duplicate first element
 Status:             Duplicate
 Type:               Bug
 Package:            Scripting Engine problem
 PHP Version:        7.4.6
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

It seems to be duplicate of #79600


Previous Comments:
------------------------------------------------------------------------
[2020-05-20 18:11:30] 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 07:17:02] cmb@php.net

Well, actually a duplicate of that bug.

------------------------------------------------------------------------
[2020-05-20 02:42:47] requinix@php.net

No doubt related to bug #78434.

------------------------------------------------------------------------
[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


Thread (7 messages)

« previous php.bugs (#227105) next »