diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-06-08 11:31:28 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-06-08 11:31:28 +0200 |
commit | df2db7fceaff4f46909f1aa8b31f0a9010631fc9 (patch) | |
tree | b8301c2dd67b7fb887e135749dd4010cbfe462c4 /Zend/tests | |
parent | 9b39ddbb85b5c589f3e7755424879f0ce012cc88 (diff) | |
download | php-git-df2db7fceaff4f46909f1aa8b31f0a9010631fc9.tar.gz |
Fixed bug #79657
Throwing an exception should count as an initialization for this
purpose.
Diffstat (limited to 'Zend/tests')
-rw-r--r-- | Zend/tests/bug79657.phpt | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Zend/tests/bug79657.phpt b/Zend/tests/bug79657.phpt new file mode 100644 index 0000000000..fb2ccab3e3 --- /dev/null +++ b/Zend/tests/bug79657.phpt @@ -0,0 +1,42 @@ +--TEST-- +Bug #79657: "yield from" hangs when invalid value encountered +--FILE-- +<?php + +function throwException(): iterable +{ + throw new Exception(); +} + +function loop(): iterable +{ + $callbacks = [ + function () { + yield 'first'; + }, + function () { + yield from throwException(); + } + ]; + + foreach ($callbacks as $callback) { + yield from $callback(); + } +} + +function get(string $first, int $second): array +{ + return []; +} + +get(...loop()); + +?> +--EXPECTF-- +Fatal error: Uncaught Exception in %s:%d +Stack trace: +#0 %s(%d): throwException() +#1 %s(%d): {closure}() +#2 %s(%d): loop() +#3 {main} + thrown in %s on line %d |