bug74954.phpt 918 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. Bug #74954 (crash after update of generator yielding from finished generator)
  3. --FILE--
  4. <?php
  5. function from() {
  6. yield 1;
  7. throw new Exception();
  8. }
  9. function gen($gen) {
  10. try {
  11. var_dump(yield from $gen);
  12. } catch (Exception $e) { print "Caught exception!\n$e\n"; }
  13. }
  14. $gen = from();
  15. $gens[] = gen($gen);
  16. $gens[] = gen($gen);
  17. foreach ($gens as $g) {
  18. $g->current();
  19. }
  20. do {
  21. foreach ($gens as $i => $g) {
  22. $g->next();
  23. }
  24. } while($gens[0]->valid());
  25. ?>
  26. --EXPECTF--
  27. Caught exception!
  28. Exception in %s:%d
  29. Stack trace:
  30. #0 %s(%d): from()
  31. #1 [internal function]: gen(Object(Generator))
  32. #2 %s(%d): Generator->next()
  33. #3 {main}
  34. Caught exception!
  35. ClosedGeneratorException: Generator yielded from aborted, no return value available in %s:%d
  36. Stack trace:
  37. #0 [internal function]: gen(Object(Generator))
  38. #1 %s(%d): Generator->next()
  39. #2 {main}