Re: [RFC] noreturn type

From: Date: Wed, 10 Mar 2021 19:21:53 +0000
Subject: Re: [RFC] noreturn type
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-113448@lists.php.net to get a copy of this message
On Wed, 10 Mar 2021 at 13:55, Rowan Tommins <rowan.collins@gmail.com> wrote:

> I am however slightly confused by what exactly the implementation
> checks, and when. Is it actually looking for "exit" and "throw" statements?
>

No. Any function annotated with : noreturn causes the engine to insert
a ZEND_VERIFY_NORETURN_TYPE op at the end of the function's operands.

If the Zend engine hits that operand — which only happens if a throw/exit
*hasn't* been encountered — it emits a TypeError.

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.
>

If a significant number agree I can add a secondary vote on noreturn vs
never, but never introduces more of a BC risk.

Best wishes,

Matt


Thread (37 messages)

« previous php.internals (#113448) next »