Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompileTimeLocation argument fails if a function has default arguments before #508

Closed
unserialize opened this issue Apr 27, 2022 · 2 comments · Fixed by #811
Closed

CompileTimeLocation argument fails if a function has default arguments before #508

unserialize opened this issue Apr 27, 2022 · 2 comments · Fixed by #811
Assignees

Comments

@FlyInk13
Copy link

Сборка падает, если 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

@unserialize
Copy link
Contributor Author

Besides, if CompileTimeLocation is not the last argument, like

function fff(int $x, ?CompileTimeLocation $loc = null, array $additional = [])

Something probably goes wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants