}
/* }}} */
-static void zend_emit_return_type_check(znode *expr, zend_arg_info *return_info) /* {{{ */
+static void zend_emit_return_type_check(
+ znode *expr, zend_arg_info *return_info, zend_bool implicit) /* {{{ */
{
/* `return ...;` is illegal in a void function (but `return;` isn't) */
if (return_info->type_hint == IS_VOID) {
if (return_info->type_hint != IS_UNDEF) {
zend_op *opline;
+ if (!expr && !implicit) {
+ zend_error_noreturn(E_COMPILE_ERROR,
+ "A function with return type must return a value");
+ }
+
if (expr && expr->op_type == IS_CONST) {
if ((return_info->type_hint == Z_TYPE(expr->u.constant))
||((return_info->type_hint == _IS_BOOL)
zend_bool returns_reference = (CG(active_op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) != 0;
if (CG(active_op_array)->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) {
- zend_emit_return_type_check(NULL, CG(active_op_array)->arg_info - 1);
+ zend_emit_return_type_check(NULL, CG(active_op_array)->arg_info - 1, 1);
}
zn.op_type = IS_CONST;
/* Generator return types are handled separately */
if (!(CG(active_op_array)->fn_flags & ZEND_ACC_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);
+ zend_emit_return_type_check(
+ expr_ast ? &expr_node : NULL, CG(active_op_array)->arg_info - 1, 0);
}
zend_handle_loops_and_finally();