Bug #76181 [Opn->Nab]: `yield`ed item is lost after sending an exception to the generator
| From: | kelunik@php.net | Date: | Tue, 03 Apr 2018 17:24:30 +0000 |
| Subject: | Bug #76181 [Opn->Nab]: `yield`ed item is lost after sending an exception to the generator | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214584@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76181&edit=1
ID: 76181
Updated by: kelunik@php.net
Reported by: samuel dot roze at gmail dot com
Summary:
yielded item is lost after sending an exception to
the generator
-Status: Open
+Status: Not a bug
Type: Bug
Package: *Programming Data Structures
Operating System: OSX
PHP Version: 7.2.4
Block user comment: N
Private report: N
New Comment:
This is not a bug. Generator::throw() advances the generator. The yielded value can be
retrieved by examining the return value of Generator::throw().
Previous Comments:
------------------------------------------------------------------------
[2018-04-03 17:06:19] samuel dot roze at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=76181&edit=1