Re: [VOTE] noreturn type

From: Date: Thu, 01 Apr 2021 17:24:35 +0000
Subject: Re: [VOTE] noreturn type
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-113920@lists.php.net to get a copy of this message
On Thu, Apr 1, 2021 at 6:07 PM Benjamin Eberlei <kontakt@beberlei.de> wrote:

>
> ```php
> if (!isset($user)) {
>    throw new NotFoundException();
> }
> ```
>

Since throw is an expression (since PHP 8.0,
https://wiki.php.net/rfc/throw_expression),
it must have a type for its
result,
as any expression has a type. And it's result is exactly noreturn (or
never, as this option seems to be preferred
judging by current vote results), because throw never returns.

It's quite natural to extend that to function calls that never return as
well. And then it makes sense to declare that type
as a part of function signature like you can do with other types.

-- 
  Best regards,
      Bruce Weirdan                                     mailto:
weirdan@gmail.com


Thread (30 messages)

« previous php.internals (#113920) next »