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

From: Date: Wed, 20 May 2020 02:22:18 +0000
Subject: Bug #79614 [NEW]: Nested 'yield from' duplicate first element
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227085@lists.php.net to get a copy of this message
From:             ponomarev at gmail dot com
Operating system: 
PHP version:      7.4.6
Package:          *General Issues
Bug Type:         Bug
Bug description:Nested 'yield from' duplicate first element

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 bug report at https://bugs.php.net/bug.php?id=79614&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79614&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79614&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79614&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79614&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79614&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79614&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79614&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79614&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79614&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79614&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79614&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79614&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79614&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79614&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79614&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79614&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79614&r=mysqlcfg


Thread (7 messages)

« previous php.bugs (#227085) next »