On Wed, Mar 10, 2021 at 2:22 PM Matthew Brown <matthewmatt...@gmail.com>
wrote:

> On Wed, 10 Mar 2021 at 13:55, Rowan Tommins <rowan.coll...@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.
>
>
I think the difference between void and noreturn is pretty clear, but, if
never is more clear, perhaps neverreturn would be an option that would be
less likely to have BC risks.

Just to throw out some additional ideas, why not two possible types: throws
and exits? Don't have any strong opinions on that, but figured I'd add it
to the discussion.


> Best wishes,
>
> Matt
>


-- 
Chase Peeler
chasepee...@gmail.com

Reply via email to