exit value in CLI). (Nikita)
. Fixed bug #62294 (register_shutdown_function() does not correctly handle
exit code). (Nikita)
+ . Fixed bug #79927 (Generator doesn't throw exception after multiple yield
+ from iterable). (Nikita)
- Date:
. Fixed bug #60302 (DateTime::createFromFormat should new static(), not new
--- /dev/null
+--TEST--
+Bug #79927: Generator doesn't throw exception after multiple yield from iterable
+--FILE--
+<?php
+
+$generator = (function () {
+ yield from [1, 2, 3];
+})();
+
+$generator->next();
+$generator->next();
+try {
+ $generator->rewind();
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+echo $generator->current(), "\n";
+
+$generator2 = (function () {
+ yield from [];
+ yield 4;
+})();
+$generator2->current();
+$generator2->rewind();
+echo $generator2->current(), "\n";
+
+?>
+--EXPECT--
+Cannot rewind a generator that was already run
+3
+4
return;
}
+ /* Drop the AT_FIRST_YIELD flag */
+ orig_generator->flags &= ~ZEND_GENERATOR_AT_FIRST_YIELD;
+
if (UNEXPECTED(!Z_ISUNDEF(generator->values))) {
if (EXPECTED(zend_generator_get_next_delegated_value(generator) == SUCCESS)) {
orig_generator->flags &= ~ZEND_GENERATOR_DO_INIT;
* after the "yield from" expression. */
}
- /* Drop the AT_FIRST_YIELD flag */
- orig_generator->flags &= ~ZEND_GENERATOR_AT_FIRST_YIELD;
-
{
/* Backup executor globals */
zend_execute_data *original_execute_data = EG(current_execute_data);