Bug #69740 [Asn->Csd]: finally in generator (yield) swallows exception in iteration

From: Date: Thu, 11 Jun 2015 15:45:44 +0000
Subject: Bug #69740 [Asn->Csd]: finally in generator (yield) swallows exception in iteration
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193330@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69740&edit=1 ID: 69740 Updated by: nikic@php.net Reported by: markus at malkusch dot de Summary: finally in generator (yield) swallows exception in iteration -Status: Assigned +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: Linux PHP Version: 5.6.9 Assigned To: nikic Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikic Revision: http://git.php.net/?p=php-src.git;a=commit;h=8405265578d2df8d76be223910b3e44aff4bdfef Log: Fix bug #69740 Previous Comments: ------------------------------------------------------------------------ [2015-06-01 15:35:39] nikic@php.net Finally handling changed a lot in PHP 5.6, probably some change was not propagated to the generators implementation. ------------------------------------------------------------------------ [2015-06-01 15:30:08] markus at malkusch dot de Description: ------------ From https://wiki.php.net/rfc/generators I learned that finally blocks are valid in Generators: > If the generator contains (relevant) finally blocks those will be run. When I iterate over such a generator and would throw an exception the exception seems to be swallowed. This behaviour was introduced in PHP-5.6 as it worked in PHP-5.5 as I would expect it: http://3v4l.org/QX4qP I can't tell if this is related to https://bugs.php.net/bug.php?id=62210. Test script: --------------- <?php function generate() { try { yield 1; yield 2; } finally { echo "finally\n"; } } foreach (generate() as $i) { echo $i, "\n"; throw new Exception(); } Expected result: ---------------- 1 finally Fatal error: Uncaught exception 'Exception' Actual result: -------------- 1 finally ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69740&edit=1

« previous php.bugs (#193330) next »