com php-src: Fix bug using not set temporary with typed generator returns: Zend/tests/generators/generator_return_return_type.phpt Zend/zend_opcode.c
| From: | Bob Weinand | Date: | Fri, 24 Jul 2015 18:31:18 +0000 |
| Subject: | com php-src: Fix bug using not set temporary with typed generator returns: Zend/tests/generators/generator_return_return_type.phpt Zend/zend_opcode.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-88150@lists.php.net to get a copy of this message | ||
Commit: 2eb845d0fa21a8ee0bce4c53ac9f1a5743a56aac
Author: Bob Weinand <bobwei9@hotmail.com> Fri, 24 Jul 2015 20:30:32 +0200
Parents: 352bf686ce8da93d7a8852eb275da2dccbdbca62
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2eb845d0fa21a8ee0bce4c53ac9f1a5743a56aac
Log:
Fix bug using not set temporary with typed generator returns
Changed paths:
A Zend/tests/generators/generator_return_return_type.phpt
M Zend/zend_opcode.c
Diff:
diff --git a/Zend/tests/generators/generator_return_return_type.phpt
b/Zend/tests/generators/generator_return_return_type.phpt
new file mode 100644
index 0000000..8045422
--- /dev/null
+++ b/Zend/tests/generators/generator_return_return_type.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Generators must return a valid variable with return type specified
+--FILE--
+<?php
+
+$gen = (function (): Generator {
+ return true;
+ yield;
+})();
+
+var_dump($gen->valid());
+var_dump($gen->getReturn());
+
+?>
+--EXPECT--
+bool(false)
+bool(true)
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index ba952a4..c42f380 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -583,7 +583,7 @@ static void zend_resolve_finally_call(zend_op_array *op_array, uint32_t op_num,
fast_call_var = op_array->opcodes[op_array->try_catch_array[i].finally_end].op1.var;
/* generate a FAST_CALL to finally block */
- start_op = get_next_op_number(op_array);
+ start_op = get_next_op_number(op_array);
opline = get_next_op(op_array);
opline->opcode = ZEND_FAST_CALL;
@@ -807,6 +807,10 @@ ZEND_API int pass_two(zend_op_array *op_array)
break;
case ZEND_VERIFY_RETURN_TYPE:
if (op_array->fn_flags & ZEND_ACC_GENERATOR) {
+ if (opline->op1_type != IS_UNUSED) {
+ (opline + 1)->op1 = opline->op1;
+ (opline + 1)->op1_type = opline->op1_type;
+ }
MAKE_NOP(opline);
}
break;