kphp
kphp copied to clipboard
CompileTimeLocation argument fails if a function has default arguments before
https://sun9-37.userapi.com/s/v1/ig2/QxnygNlZyl5hjcni3Xij8tS09WPC__LCLiqgxImuSygAhbXYKqkLhJztFhFd1VLWRWDJv-bjMFZp8ejT19kH0JWF.jpg?size=1119x961&quality=96&type=album
Сборка падает, если CompileTimeLocation перед необязательным аргументом, т.к. объект подставляется не на своё место.
Минимальный код для воспроизведения:
function logError(?int $code = null, \CompileTimeLocation $loc = null): string {
$loc = \CompileTimeLocation::calculate($compile_time_location);
return "test (in {$loc->function} at {$loc->file}:{$loc->line})\n";
}
logError();
Вывод:
Starting php to cpp transpiling...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compilation error at stage: Calc actual calls, gen by type-inferer.cpp:53
test.php:7 in global scope
pass CompileTimeLocation to argument $code of logError
but it's declared as @param ?int
test.php:7 in global scope
new CompileTimeLocation returns CompileTimeLocation
Compilation terminated due to errors