Skip to content

Drop support for multiple generators yielding from one generator #6071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Zend/tests/generators/bug70965.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Bug #70965 (yield from with a common iterator primes too much)
Bug #70965 (yield from with a common iterator primes too much) (no longer supported)
--FILE--
<?php

Expand All @@ -23,10 +23,12 @@ do {
} while ($gen->valid());

?>
--EXPECT--
--EXPECTF--
int(1)
int(2)
int(3)
int(4)
int(5)
int(5)

Fatal error: Uncaught Error: A different generator already yields from this generator in %s:%d
Stack trace:
#0 [internal function]: bar(Object(Generator))
#1 %s(%d): Generator->current()
#2 {main}
thrown in %s on line %d
15 changes: 4 additions & 11 deletions Zend/tests/generators/bug74954.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Bug #74954 (crash after update of generator yielding from finished generator)
Bug #74954 (crash after update of generator yielding from finished generator) (no longer supported)
--FILE--
<?php

Expand Down Expand Up @@ -30,16 +30,9 @@ do {

?>
--EXPECTF--
Caught exception!
Exception in %s:%d
Stack trace:
#0 %s(%d): from()
#1 [internal function]: gen(Object(Generator))
#2 %s(%d): Generator->next()
#3 {main}
Caught exception!
ClosedGeneratorException: Generator yielded from aborted, no return value available in %s:%d
Fatal error: Uncaught Error: A different generator already yields from this generator in %s:%d
Stack trace:
#0 [internal function]: gen(Object(Generator))
#1 %s(%d): Generator->next()
#1 %s(%d): Generator->current()
#2 {main}
thrown in %s on line %d
13 changes: 10 additions & 3 deletions Zend/tests/generators/gc_with_root_parent_mismatch.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Generator GC when the yield from parent chain does not reach the root
Generator GC when the yield from parent chain does not reach the root (no longer supported)
--FILE--
<?php

Expand All @@ -22,6 +22,13 @@ $gen1->next();
gc_collect_cycles();

?>
--EXPECT--
int(1)
--EXPECTF--
int(1)

Fatal error: Uncaught Error: A different generator already yields from this generator in %s:%d
Stack trace:
#0 %s(%d): delegate(Object(Generator))
#1 [internal function]: delegate(Object(Generator))
#2 %s(%d): Generator->current()
#3 {main}
thrown in %s on line %d
20 changes: 9 additions & 11 deletions Zend/tests/generators/multiple_yield_from_on_same_generator.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Multiple yield from on a same Generator instance
Multiple yield from on a same Generator instance (no longer supported)
--FILE--
<?php

Expand Down Expand Up @@ -30,14 +30,12 @@ do {
var_dump($gens[1]->valid());

?>
--EXPECT--
--EXPECTF--
int(1)
int(2)
int(4)
int(6)
int(3)
int(5)
int(3)
int(5)
NULL
bool(false)

Fatal error: Uncaught Error: A different generator already yields from this generator in %s:%d
Stack trace:
#0 [internal function]: bar(Object(Generator))
#1 %s(%d): Generator->current()
#2 {main}
thrown in %s on line %d
17 changes: 3 additions & 14 deletions Zend/tests/generators/mutli_yield_from_with_exception.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--TEST--
Multiple yield from on a same Generator throwing an Exception
Multiple yield from on a same Generator throwing an Exception (no longer supported)
--FILE--
<?php
function from() {
Expand Down Expand Up @@ -30,20 +30,9 @@ do {
} while($gens[0]->valid());
?>
--EXPECTF--
Generator 0
int(1)
Caught exception!
Exception in %s:%d
Stack trace:
#0 %s(%d): from()
#1 [internal function]: gen(Object(Generator))
#2 %s(%d): Generator->next()
#3 {main}
Generator 1
Caught exception!
ClosedGeneratorException: Generator yielded from aborted, no return value available in %s:%d
Fatal error: Uncaught Error: A different generator already yields from this generator in %s:%d
Stack trace:
#0 [internal function]: gen(Object(Generator))
#1 %s(%d): Generator->current()
#2 {main}
NULL
thrown in %s on line %d
27 changes: 27 additions & 0 deletions Zend/tests/generators/yield_from_multi_child_destroyed.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
Yield from by multiple generators where a child is destroyed before the parent (no longer supported)
--FILE--
<?php

function gen() {
yield 42;
}

function yield_from($gen) {
yield from $gen;
}

$gen = gen();
var_dump(yield_from($gen)->current());
var_dump(yield_from($gen)->current());

?>
--EXPECTF--
int(42)

Fatal error: Uncaught Error: A different generator already yields from this generator in %s:%d
Stack trace:
#0 [internal function]: yield_from(Object(Generator))
#1 %s(%d): Generator->current()
#2 {main}
thrown in %s on line %d
Loading