On Mon, Feb 23, 2026, 4:23 PM Mirco Babin <[email protected]> wrote:
> Op za 21 feb 2026 om 17:28 schreef Rowan Tommins [IMSoP] < > [email protected]>: > > > > On 20 February 2026 16:07:01 GMT, Mirco Babin <[email protected]> > wrote: > > >Failing early is not always possible. The compiler can not always infere > > >the correct return type. > > > > PHP defines "void" separately from "null", precisely so that the compiler > > doesn't need to infer anything about the returned value. All it has to do > > is distinguish "return;" from "return some_expression;" > > > > Example: https://3v4l.org/cTaBP > > > > That is a very good find. Are the following claims correct? > > > In all cases it would be a compile error, because the compiler only > checks "return something;" vs. "return;". > > It would never throw a TypeError at runtime. that's correct, as the return statement will have an expression, it will be detected. absence of return is equivalent to return; as well. you can see it using the ast extension, that may help you to see what can or cannot be check at compile vs runtime, I general. the engine does many compile time checks but not as much as a static analyzers or a compiled language can do, but things similar to this are cheap and usually done. best, -- Pierre @pierrejoye | http://www.libgd.org
