summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/tests/generators/throw_caught.phpt2
-rw-r--r--Zend/tests/generators/throw_rethrow.phpt2
-rw-r--r--Zend/zend_generators.c2
3 files changed, 6 insertions, 0 deletions
diff --git a/Zend/tests/generators/throw_caught.phpt b/Zend/tests/generators/throw_caught.phpt
index 0c3f8e9b2d..c5e9d81ebc 100644
--- a/Zend/tests/generators/throw_caught.phpt
+++ b/Zend/tests/generators/throw_caught.phpt
@@ -4,6 +4,7 @@ Generator::throw() where the exception is caught in the generator
<?php
function gen() {
+ echo "before yield\n";
try {
yield;
} catch (RuntimeException $e) {
@@ -18,6 +19,7 @@ var_dump($gen->throw(new RuntimeException('Test')));
?>
--EXPECTF--
+before yield
exception 'RuntimeException' with message 'Test' in %s:%d
Stack trace:
#0 {main}
diff --git a/Zend/tests/generators/throw_rethrow.phpt b/Zend/tests/generators/throw_rethrow.phpt
index 267f5f0db8..65044ee3f3 100644
--- a/Zend/tests/generators/throw_rethrow.phpt
+++ b/Zend/tests/generators/throw_rethrow.phpt
@@ -4,6 +4,7 @@ Generator::throw() where the generator throws a different exception
<?php
function gen() {
+ echo "before yield\n";
try {
yield;
} catch (RuntimeException $e) {
@@ -18,6 +19,7 @@ var_dump($gen->throw(new RuntimeException('throw')));
?>
--EXPECTF--
+before yield
Caught: exception 'RuntimeException' with message 'throw' in %s:%d
Stack trace:
#0 {main}
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index aca15c2a88..e121e3c92a 100644
--- a/Zend/zend_generators.c
+++ b/Zend/zend_generators.c
@@ -560,6 +560,8 @@ ZEND_METHOD(Generator, throw)
generator = (zend_generator *) zend_object_store_get_object(getThis() TSRMLS_CC);
+ zend_generator_ensure_initialized(generator TSRMLS_CC);
+
if (generator->execute_data) {
/* Throw the exception in the context of the generator */
zend_execute_data *current_execute_data = EG(current_execute_data);