Bug #76181 [NEW]: `yield`ed item is lost after sending an exception to the generator
| From: | samuel dot roze at gmail dot com | Date: | Tue, 03 Apr 2018 17:06:20 +0000 |
| Subject: | Bug #76181 [NEW]: `yield`ed item is lost after sending an exception to the generator | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-214582@lists.php.net to get a copy of this message | ||
From: samuel dot roze at gmail dot com
Operating system: OSX
PHP version: 7.2.4
Package: *Programming Data Structures
Bug Type: Bug
Bug description:
yielded item is lost after sending an exception to the generator
Description:
------------
When calling throw($e) on a Generator while iterating over it, it
looks like it "lose" one of the items that have been yielded.
See the following Gist:
https://gist.github.com/sroze/2ed22483b5fd35081b4fa31f02fd1a24#file-bug-example-php
Test script:
---------------
https://gist.githubusercontent.com/sroze/2ed22483b5fd35081b4fa31f02fd1a24/raw/b91b113e48f4730358fe75a4661bd5531b553d14/bug-example.php
Expected result:
----------------
Got exception do nothing
Got message test2
Got message test3
Actual result:
--------------
Got exception do nothing
Got message test3
--
Edit bug report at https://bugs.php.net/bug.php?id=76181&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76181&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76181&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76181&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76181&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76181&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76181&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76181&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76181&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76181&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76181&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76181&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76181&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76181&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76181&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76181&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76181&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76181&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76181&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76181&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76181&r=mysqlcfg