Re: [RFC] [VOTE] Transform exit() from a language construct into a standard function
| From: | Tim Düsterhus | Date: | Mon, 05 Aug 2024 17:11:43 +0000 |
| Subject: | Re: [RFC] [VOTE] Transform exit() from a language construct into a standard function | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-124782@lists.php.net to get a copy of this message | ||
Hi
On 8/5/24 18:06, Levi Morrison wrote:
After thinking about this several times over the course of discussion and again now that it's in voting, I have decided to vote no. I am in favor of this change, I just think given the concerns it's best to wait for PHP 9.0 to do it. Maybe the concerns with control flow can be improved by better inference/marking of functions which areAs I've just explained in my response to Derick within the discussion thread related to this RFC: The information is already there, it just needs to be used. For a test I've just added the following code snippet tonoreturn, at least for known functions (of which\exitdefinitely would be).
zend_compile_call():
zend_type return_type = fbc->common.arg_info[-1].type;
if (ZEND_TYPE_CONTAINS_CODE(return_type, IS_NEVER)) {
printf("%s has return type never\n", ZSTR_VAL(lcname));
} else {
printf("%s doesn't have return type never\n", ZSTR_VAL(lcname));
}
and then I executed the following test script:
<?php
namespace Foo;
function a() {
\strrev('foo');
exit(new \stdClass());
}
try {
a();
} catch (\Throwable) {}
echo "executed", PHP_EOL;
when running this script, I receive the following output:
strrev doesn't have return type never
exit has return type never
executed
Best regards
Tim Düsterhus