bug79657.phpt 683 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Bug #79657: "yield from" hangs when invalid value encountered
  3. --FILE--
  4. <?php
  5. function throwException(): iterable
  6. {
  7. throw new Exception();
  8. }
  9. function loop(): iterable
  10. {
  11. $callbacks = [
  12. function () {
  13. yield 'first';
  14. },
  15. function () {
  16. yield from throwException();
  17. }
  18. ];
  19. foreach ($callbacks as $callback) {
  20. yield from $callback();
  21. }
  22. }
  23. function get(string $first, int $second): array
  24. {
  25. return [];
  26. }
  27. get(...loop());
  28. ?>
  29. --EXPECTF--
  30. Fatal error: Uncaught Exception in %s:%d
  31. Stack trace:
  32. #0 %s(%d): throwException()
  33. #1 %s(%d): {closure}()
  34. #2 %s(%d): loop()
  35. #3 {main}
  36. thrown in %s on line %d