kphp icon indicating copy to clipboard operation
kphp copied to clipboard

Wrong `rl_type` for `new B` in `echo`

Open i582 opened this issue 3 years ago • 0 comments

Minimal example

class B {
  public function __toString(): void {
    echo 1;
  }
}

echo new B();

Expected

Сompile-time error about using the result of a void function.

Actual

At the moment we will give an error that the return type of __toString is not a string, however, the void check will happen earlier and should be issued first, but it is not issued. Apparently, this is due to an incorrect calculation of rl_type, which is why the condition is not match any in FixReturnsPass.

i582 avatar Oct 17 '21 18:10 i582