summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2016-06-10 15:57:18 +0200
committerNikita Popov <nikic@php.net>2016-06-10 15:57:18 +0200
commit792e89385ca6fc722a03590722eb7745a2374720 (patch)
treeafc5bb12434e3a462f8e3fd331ecd31abb7ed3ea
parent33f6fc1790358883873b2b894d2b4af801f374fc (diff)
downloadphp-git-792e89385ca6fc722a03590722eb7745a2374720.tar.gz
Fixed bug #72373
-rw-r--r--NEWS3
-rw-r--r--Zend/tests/bug72373.phpt20
-rw-r--r--Zend/zend_compile.c3
3 files changed, 25 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index de57cceff7..e67720a5a8 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2016, PHP 7.1.0alpha2
+- Core:
+ . Fixed bug #72373 (TypeError after Generator function w/declared return type
+ finishes). (Nikita)
09 Jun 2016, PHP 7.1.0alpha1
diff --git a/Zend/tests/bug72373.phpt b/Zend/tests/bug72373.phpt
new file mode 100644
index 0000000000..67377c5ba7
--- /dev/null
+++ b/Zend/tests/bug72373.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #72373: TypeError after Generator function w/declared return type finishes
+--FILE--
+<?php
+
+function foo() : Generator {
+ yield 1;
+ yield 2;
+ yield 3;
+}
+
+foreach (foo() as $bar) {
+ echo $bar . "\n";
+}
+
+?>
+--EXPECT--
+1
+2
+3
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 30d28cd842..2b935a8f4d 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -2329,7 +2329,8 @@ void zend_emit_final_return(int return_one) /* {{{ */
zend_op *ret;
zend_bool returns_reference = (CG(active_op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0;
- if (CG(active_op_array)->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
+ if (CG(active_op_array)->fn_flags & ZEND_ACC_HAS_RETURN_TYPE
+ && !(CG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR)) {
zend_emit_return_type_check(NULL, CG(active_op_array)->arg_info - 1, 1);
}