Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Zend/tests/partial_application/never_return.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
PFA can be made from never function
--FILE--
<?php

function neverReturns($msg): never {
throw new Error($msg);
}

var_dump(neverReturns(?) instanceof Closure);

?>
--EXPECT--
bool(true)
4 changes: 2 additions & 2 deletions Zend/zend_partial.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ static zend_ast *zp_compile_forwarding_call(
call_ast = zend_ast_create(ZEND_AST_CALL, func_name_ast, args_ast);
}

/* Void functions can not 'return $expr' */
if (ZEND_TYPE_FULL_MASK(return_type) & MAY_BE_VOID) {
/* Void and never functions can not 'return $expr' */
if (ZEND_TYPE_FULL_MASK(return_type) & (MAY_BE_VOID|MAY_BE_NEVER)) {
stmts_ast = zend_ast_list_add(stmts_ast, call_ast);
} else {
zend_ast *return_ast = zend_ast_create(ZEND_AST_RETURN, call_ast);
Expand Down
Loading