Re: [RFC] noreturn type

From: Date: Wed, 10 Mar 2021 18:55:14 +0000
Subject: Re: [RFC] noreturn type
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-113446@lists.php.net to get a copy of this message
On 10/03/2021 18:06, Matthew Brown wrote:
Ondřej Mirtes and I present an RFC for the noreturn type: https://wiki.php.net/rfc/noreturn_type
Thanks for the proposal, I can certainly think of uses for it. I am however slightly confused by what exactly the implementation checks, and when. Is it actually looking for "exit" and "throw" statements? The text talks about exiting "explicitly or implicitly", but doesn't give any examples of how this works. For instance, is this code valid, and how does PHP know that it's valid? function my_exit(string $reason): noreturn {
    exit("$reason\n");
} function canned_exit(): noreturn {    my_exit("The normal reason"); } The other thing I'd like to mention is that PHP's implementation of "void" consists mostly of checking that there is no return statement, so a separate keyword of "noreturn" may well cause confusion. I would personally prefer the name "never" for this reason. Regards, -- Rowan Tommins [IMSoP]

Thread (37 messages)

« previous php.internals (#113446) next »