summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/tests/generators/generator_return_return_type.phpt5
-rw-r--r--Zend/zend_compile.c2
-rw-r--r--Zend/zend_opcode.c29
3 files changed, 18 insertions, 18 deletions
diff --git a/Zend/tests/generators/generator_return_return_type.phpt b/Zend/tests/generators/generator_return_return_type.phpt
index 804542285f..345e0065c2 100644
--- a/Zend/tests/generators/generator_return_return_type.phpt
+++ b/Zend/tests/generators/generator_return_return_type.phpt
@@ -4,8 +4,9 @@ Generators must return a valid variable with return type specified
<?php
$gen = (function (): Generator {
- return true;
- yield;
+ 1 + $a = 1; // force a temporary
+ return true;
+ yield;
})();
var_dump($gen->valid());
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 64ad77d4a7..f0ddbd478b 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -3610,7 +3610,7 @@ void zend_resolve_goto_label(zend_op_array *op_array, znode *label_node, zend_op
znode *loop_var = NULL;
if (pass2_opline) {
- label = RT_CONSTANT(op_array, pass2_opline->op2);
+ label = CT_CONSTANT_EX(op_array, pass2_opline->op2.constant);
} else {
label = &label_node->u.constant;
}
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index c42f3807e4..da401e17b9 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -693,7 +693,6 @@ static void zend_resolve_finally_calls(zend_op_array *op_array)
break;
case ZEND_GOTO:
if (Z_TYPE_P(CT_CONSTANT_EX(op_array, opline->op2.constant)) != IS_LONG) {
- ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline->op2);
zend_resolve_goto_label(op_array, NULL, opline);
}
/* break omitted intentionally */
@@ -744,19 +743,6 @@ ZEND_API int pass_two(zend_op_array *op_array)
opline = op_array->opcodes;
end = opline + op_array->last;
while (opline < end) {
- if (opline->op1_type == IS_CONST) {
- ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline->op1);
- } else if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) {
- opline->op1.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + opline->op1.var);
- }
- if (opline->op2_type == IS_CONST) {
- ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline->op2);
- } else if (opline->op2_type & (IS_VAR|IS_TMP_VAR)) {
- opline->op2.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + opline->op2.var);
- }
- if (opline->result_type & (IS_VAR|IS_TMP_VAR)) {
- opline->result.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + opline->result.var);
- }
switch (opline->opcode) {
case ZEND_DECLARE_ANON_INHERITED_CLASS:
ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1);
@@ -776,7 +762,7 @@ ZEND_API int pass_two(zend_op_array *op_array)
}
break;
case ZEND_GOTO:
- if (Z_TYPE_P(RT_CONSTANT(op_array, opline->op2)) != IS_LONG) {
+ if (Z_TYPE_P(CT_CONSTANT_EX(op_array, opline->op2.constant)) != IS_LONG) {
zend_resolve_goto_label(op_array, NULL, opline);
}
/* break omitted intentionally */
@@ -821,6 +807,19 @@ ZEND_API int pass_two(zend_op_array *op_array)
}
break;
}
+ if (opline->op1_type == IS_CONST) {
+ ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline->op1);
+ } else if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) {
+ opline->op1.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + opline->op1.var);
+ }
+ if (opline->op2_type == IS_CONST) {
+ ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline->op2);
+ } else if (opline->op2_type & (IS_VAR|IS_TMP_VAR)) {
+ opline->op2.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + opline->op2.var);
+ }
+ if (opline->result_type & (IS_VAR|IS_TMP_VAR)) {
+ opline->result.var = (uint32_t)(zend_intptr_t)ZEND_CALL_VAR_NUM(NULL, op_array->last_var + opline->result.var);
+ }
ZEND_VM_SET_OPCODE_HANDLER(opline);
opline++;
}