com php-src: Fixed bug #72373: NEWS Zend/tests/bug72373.phpt Zend/zend_compile.c

From: Date: Fri, 10 Jun 2016 13:57:18 +0000
Subject: com php-src: Fixed bug #72373: NEWS Zend/tests/bug72373.phpt Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-92355@lists.php.net to get a copy of this message
Commit: 792e89385ca6fc722a03590722eb7745a2374720 Author: Nikita Popov <nikic@php.net> Fri, 10 Jun 2016 15:57:18 +0200 Parents: 33f6fc1790358883873b2b894d2b4af801f374fc Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=792e89385ca6fc722a03590722eb7745a2374720 Log: Fixed bug #72373 Bugs: https://bugs..php.net/72373 Changed paths: M NEWS A Zend/tests/bug72373.phpt M Zend/zend_compile.c Diff: diff --git a/NEWS b/NEWS index de57cce..e67720a 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 0000000..67377c5 --- /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 30d28cd..2b935a8 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); }

« previous php.cvs (#92355) next »