]> granicus.if.org Git - php/commitdiff
Fixed bug #72373
authorNikita Popov <nikic@php.net>
Fri, 10 Jun 2016 13:57:18 +0000 (15:57 +0200)
committerNikita Popov <nikic@php.net>
Fri, 10 Jun 2016 13:57:18 +0000 (15:57 +0200)
NEWS
Zend/tests/bug72373.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/NEWS b/NEWS
index de57cceff7f97815f104ae03d38e572242c3116e..e67720a5a8cf4baf9e13f2eb3389e72b9abec96e 100644 (file)
--- 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 (file)
index 0000000..67377c5
--- /dev/null
@@ -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
index 30d28cd842b1e152bdc888d14d56af4499a2926c..2b935a8f4db010942a247d353bf2d3a0ff6761af 100644 (file)
@@ -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);
        }