1
0
mirror of https://github.com/php/php-src.git synced 2026-04-24 00:18:23 +02:00
Files
archived-php-src/Zend/tests/generators/yield_from_force_closed.phpt
T
Nikita Popov 4746e5efcb Forbid "yield from" in force closed generators
Same check we do for "yield", was missed when "yield from" was
added. We could make this more granular by only forbidding to
actually yield values and still allow something like "yield from []",
but this does not seem worthwhile.
2016-05-28 13:21:05 +02:00

38 lines
527 B
PHP

--TEST--
Cannot "yield from" from force closed generator
--FILE--
<?php
function gen1() {
echo "gen1\n";
yield 1;
}
function gen2() {
try {
echo "try\n";
yield from gen1();
} finally {
echo "finally\n";
yield from gen1();
}
}
try {
$gen = gen2();
$gen->rewind();
unset($gen);
} catch (Error $e) {
echo $e, "\n";
}
?>
--EXPECTF--
try
gen1
finally
Error: Cannot use "yield from" in a force-closed generator in %s:%d
Stack trace:
#0 %s(%d): gen2()
#1 {main}