com php-src: Revert "Reorder the oplines" (Break Zend/tests/ret urn_types/bug71092.phpt): Zend/tests/return _types/029.phpt Zend/zend_compile.c
ext/opcac he/Optimizer/zend_optimizer.c
| From: | Xinchen Hui | Date: | Wed, 21 Dec 2016 06:24:14 +0000 |
| Subject: | com php-src: Revert "Reorder the oplines" (Break Zend/tests/ret urn_types/bug71092.phpt): Zend/tests/return _types/029.phpt Zend/zend_compile.c ext/opcac he/Optimizer/zend_optimizer.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96399@lists.php.net to get a copy of this message | ||
Commit: 82988d3e419c4537e6e5db30c4ea511c4abf29f6
Author: Xinchen Hui <laruence@gmail.com> Wed, 21 Dec 2016 14:24:14 +0800
Parents: 7e2146293bb4bd7d65725e16c859f62a8d4383b5
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=82988d3e419c4537e6e5db30c4ea511c4abf29f6
Log:
Revert "Reorder the oplines" (Break Zend/tests/return_types/bug71092.phpt)
This reverts commit a12f43ee2c3d27a7eb9a3c873901643df5f7197e.
Bugs:
https://bugs.php.net/71092
Changed paths:
M Zend/tests/return_types/029.phpt
M Zend/zend_compile.c
M ext/opcache/Optimizer/zend_optimizer.c
Diff:
diff --git a/Zend/tests/return_types/029.phpt b/Zend/tests/return_types/029.phpt
index af13e6a..adc07cd 100644
--- a/Zend/tests/return_types/029.phpt
+++ b/Zend/tests/return_types/029.phpt
@@ -16,8 +16,13 @@ function foo() : array {
foo();
?>
--EXPECTF--
-Fatal error: Uncaught TypeError: Return value of foo() must be of the type array, null returned in
%s029.php:%d
+Fatal error: Uncaught Exception: xxxx in %s:%d
Stack trace:
-#0 %s: foo()
+#0 %s(%d): foo()
#1 {main}
- thrown in %s on line %d
+
+Next TypeError: Return value of foo() must be of the type array, null returned in %s29.php:%d
+Stack trace:
+#0 %s(%d): foo()
+#1 {main}
+ thrown in %s029.php on line %d
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 71599e0..c8f2eef 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4209,14 +4209,14 @@ void zend_compile_return(zend_ast *ast) /* {{{ */
}
}
- zend_handle_loops_and_finally((expr_node.op_type & (IS_TMP_VAR | IS_VAR)) ? &expr_node :
NULL);
-
/* Generator return types are handled separately */
if (!is_generator && CG(active_op_array)->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
zend_emit_return_type_check(
expr_ast ? &expr_node : NULL, CG(active_op_array)->arg_info - 1, 0);
}
+ zend_handle_loops_and_finally((expr_node.op_type & (IS_TMP_VAR | IS_VAR)) ? &expr_node :
NULL);
+
opline = zend_emit_op(NULL, by_ref ? ZEND_RETURN_BY_REF : ZEND_RETURN,
&expr_node, NULL);
diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c
index 5c6b690..fa86b99 100644
--- a/ext/opcache/Optimizer/zend_optimizer.c
+++ b/ext/opcache/Optimizer/zend_optimizer.c
@@ -506,7 +506,6 @@ int zend_optimizer_replace_by_const(zend_op_array *op_array,
}
case ZEND_VERIFY_RETURN_TYPE: {
zend_arg_info *ret_info = op_array->arg_info - 1;
- ZEND_ASSERT((opline + 1)->opcode == ZEND_RETURN || (opline + 1)->opcode ==
ZEND_RETURN_BY_REF);
if (ret_info->class_name
|| ret_info->type_hint == IS_CALLABLE
|| !ZEND_SAME_FAKE_TYPE(ret_info->type_hint, Z_TYPE_P(val))
@@ -515,7 +514,13 @@ int zend_optimizer_replace_by_const(zend_op_array *op_array,
return 0;
}
MAKE_NOP(opline);
- ++opline;
+
+ /* zend_handle_loops_and_finally may inserts other oplines */
+ do {
+ ++opline;
+ } while (opline->opcode != ZEND_RETURN && opline->opcode != ZEND_RETURN_BY_REF);
+ ZEND_ASSERT(ZEND_OP1(opline).var == var);
+
break;
}
default: