[php-src] Issue #7900: `never` return type for arrow functions with throw expressions
| From: | iluuu1994 | Date: | Fri, 07 Jan 2022 12:21:24 +0000 |
| Subject: | [php-src] Issue #7900: `never` return type for arrow functions with throw expressions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-238851@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7900
Comment Author: iluuu1994
> There is no way to generate a "void" value without a return; or ending a function
> without statement.
The absence of a
return also generates a "void" value. A normal
arrow function essentially gets rewritten to this:
```php
fn (): void => voidFn();
function (): int {
return voidFn();
}
```
It should be safe to drop the implicit return here.
The controversial part comes from the fact that now this would also be valid code:
```php
fn (): void => 42;
function (): int {
42;
}
```