You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
to cater for the fact that enums are not supported in KPHP (the code base I am trying to convert uses many enums), I would expect the transpiler to be able to deduce that the above statement can be re-written as:
$user = cfg('USER', CfgType::STRING());
since KPHP_VERSION is defined to be 1 when compiling with KPHP (and the else part of the ternary will only be taken when running in a PHP context)
However, if I compile like this:
# kphp main.php --mode server --include-dir $(pwd) -o ./server
I get this error:
Compilation error at stage: Calc actual calls, gen by type-inferer.cpp:53
main.php:14 in global scope
$user = (KPHP_VERSION) ? cfg('USER', CfgType::STRING()) : cfg('USER', CfgType::STRING);
pass int to argument $type of cfg
but it's declared as @param CfgType main.php:14 in global scope $user = (KPHP_VERSION) ? cfg('USER', CfgType::STRING()) : cfg('USER', CfgType::STRING); 1 is int
apparently because it takes the else part into account ?
I would like to be able to do assignments like ($user = ) on a single line.
However, I am aware that the $user = ... line can be replaced by:
#ifndef KPHP // PHP$user = cfg('USER', CfgType::STRING);
if (FALSE) { // KPHP#endif$user = cfg('USER', CfgType::STRING());
#ifndef KPHP // PHP
}
#endif
but that syntax is rather cumbersome ...
So can't the transpiler be improved in this regard ?
The text was updated successfully, but these errors were encountered:
If I do someting like:
EmulatedEnumInt.php
:CfgType.php
:code.php
:main.php:
to cater for the fact that enums are not supported in KPHP (the code base I am trying to convert uses many enums), I would expect the transpiler to be able to deduce that the above statement can be re-written as:
since KPHP_VERSION is defined to be 1 when compiling with KPHP (and the else part of the ternary will only be taken when running in a PHP context)
However, if I compile like this:
# kphp main.php --mode server --include-dir $(pwd) -o ./server
I get this error:
apparently because it takes the else part into account ?
I would like to be able to do assignments like ($user = ) on a single line.
However, I am aware that the
$user = ...
line can be replaced by:The text was updated successfully, but these errors were encountered: