diff options
| author | Xinchen Hui <laruence@gmail.com> | 2016-12-17 20:06:18 +0800 |
|---|---|---|
| committer | Xinchen Hui <laruence@gmail.com> | 2016-12-17 20:06:18 +0800 |
| commit | a12f43ee2c3d27a7eb9a3c873901643df5f7197e (patch) | |
| tree | 3899eb397c0d82d137bc39f79d1dd72c84f1a1bf /Zend | |
| parent | 8ba7878f1b88f760d1cf483321e2ac1b27a93c58 (diff) | |
| download | php-git-a12f43ee2c3d27a7eb9a3c873901643df5f7197e.tar.gz | |
Reorder the oplines
1. we should only do the return type checking when it is really about to
return
2. for 029.php, actually, the exception threw should be discard while it
jmp into finally(it could be observed by change the return to return an array)
3. after this fix, the test 029.phpt behavior consistently with 7.0
4. good for optimizer too
Diffstat (limited to 'Zend')
| -rw-r--r-- | Zend/tests/return_types/029.phpt | 11 | ||||
| -rw-r--r-- | Zend/zend_compile.c | 4 |
2 files changed, 5 insertions, 10 deletions
diff --git a/Zend/tests/return_types/029.phpt b/Zend/tests/return_types/029.phpt index adc07cde7f..af13e6a699 100644 --- a/Zend/tests/return_types/029.phpt +++ b/Zend/tests/return_types/029.phpt @@ -16,13 +16,8 @@ function foo() : array { foo(); ?> --EXPECTF-- -Fatal error: Uncaught Exception: xxxx in %s:%d +Fatal error: Uncaught TypeError: Return value of foo() must be of the type array, null returned in %s029.php:%d Stack trace: -#0 %s(%d): foo() +#0 %s: foo() #1 {main} - -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 + thrown in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index c8f2eefa7d..71599e0e08 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); |
