mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
e25aab6426
We need to unset the AT_FIRST_YIELD flag when yielding from an array as well. In the interest of being conservative, I'm applying this only to PHP 8.
32 lines
549 B
PHP
32 lines
549 B
PHP
--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
|