Re: [VOTE] noreturn type

From: Date: Sat, 03 Apr 2021 19:26:34 +0000
Subject: Re: [VOTE] noreturn type
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-113940@lists.php.net to get a copy of this message
On Sat, 3 Apr 2021 at 17:30, Benjamin Eberlei <kontakt@beberlei.de> wrote: > The problem is that "void" is already not perfect, since the callside > doesn't care about "return null" with no return type vs "return" + > void > return type. > > If we had "nothing" and "null" instead of "void", and we'd > say like PHP > works, "return;" actually means "return null;", then: > > function foo(): nothing { > return; // Error: cannot return null from a function that returns > nothing. > } > function bar(): null { > return; > // or return null; > } > > This would more consistently tie into union types where |null is allowed, > however on its own it is not: "foo() : null => error". > > As Levi said, this noreturn/never just perpetuates/amplifies the existing > void mistake and feels off, given that other recent changes to PHP have > been more bold, towards removing inconsistencies. > This and Levi's email make compelling arguments and I would like to see this adopted. I have changed my vote to "No". Peter

« previous php.internals (#113940) next »