Den søn. 16. jun. 2019 kl. 02.48 skrev Wes <netmo....@gmail.com>:
>
> Hi Kalle. I hope it's feasible. Unfortunately I don't know much about
> internals. Any info on the matter would be very appreciated, though :P
>
> Anyway, if we can scan the function body to complain about `return null;`
> when the function is `:void`, surely we can scan just the very top of the
> function body to read the imports :P

The latter is detected at a different stage, we can detect some type
errors during the language parser phase, for your example if the
prototype of the function/method has a return type set to void, then
any return statements within the body causes an error, while most
other errors happens at runtime:

function invalid() : string {
  return null;
}

Will first throw an error the moment it is called, not when it is
parsed unlike your example.

The problem here is that you cannot perform that binding of a variable
until the runtime kicks in (you don't know if $a exists until you
attempt at binding it which must be at the time the closure is
created, not when executed from an engine perspective).


(Also, regarding the other email you sent to Moe, please keep this
language and such comments off the list and in private, such does not
belong to internals, it is a mailing list about the development of a
programming language, not a kinder garden)


-- 
regards,

Kalle Sommer Nielsen
ka...@php.net

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to