mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
parent
3b5b288127
commit
08e6c20955
14
Zend/tests/return_ref_none.phpt
Normal file
14
Zend/tests/return_ref_none.phpt
Normal file
@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
Argument-less return from by-ref function
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function &test() {
|
||||
return;
|
||||
}
|
||||
|
||||
$ref =& test();
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Notice: Only variable references should be returned by reference in %s on line %d
|
@ -4631,14 +4631,14 @@ void zend_compile_return(zend_ast *ast) /* {{{ */
|
||||
by_ref = 0;
|
||||
}
|
||||
|
||||
if (by_ref && zend_ast_is_short_circuited(expr_ast)) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "Cannot take reference of a nullsafe chain");
|
||||
}
|
||||
|
||||
if (!expr_ast) {
|
||||
expr_node.op_type = IS_CONST;
|
||||
ZVAL_NULL(&expr_node.u.constant);
|
||||
} else if (by_ref && zend_is_variable(expr_ast)) {
|
||||
if (zend_ast_is_short_circuited(expr_ast)) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "Cannot take reference of a nullsafe chain");
|
||||
}
|
||||
|
||||
zend_compile_var(&expr_node, expr_ast, BP_VAR_W, 1);
|
||||
} else {
|
||||
zend_compile_expr(&expr_node, expr_ast);
|
||||
|
Loading…
Reference in New Issue
Block a user