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
PHPCfg\Parser::parseExpr_Ternary() lowers ?: to CFG branches, but lib/Compiler.php has no handler for the resulting ops—any script using ternaries hits Unsupported expression.
Ternaries are ubiquitous in web apps (defaults, inline HTML flags, routing).
Goal
$x = $cond ? $a : $b compiles on VM, JIT, and AOT.
lib/Compiler.php: extend compileExpr() (or dedicated helper) for the ternary CFG op php-cfg emits after parseExpr_Ternary() — likely not a single Op\Expr\* node; trace with bin/print.php before guessing opcode names.
Lowering pattern: evaluate condition → TYPE_JUMPIF to true/false blocks → compile each arm → phi/assign merge to target variable (mirror compileSwitchStmt block linking).
lib/VM.php: both arms must produce compatible stack types; document mixed string/int behavior vs Zend.
lib/JIT.php: LLVM branch + Builder::phi at merge block for SSA values.
Problem
PHPCfg\Parser::parseExpr_Ternary()lowers?:to CFG branches, butlib/Compiler.phphas no handler for the resulting ops—any script using ternaries hitsUnsupported expression.Ternaries are ubiquitous in web apps (defaults, inline HTML flags, routing).
Goal
$x = $cond ? $a : $bcompiles on VM, JIT, and AOT.Implementation hints
bin/print.php -r '$x = $a ? $b : $c;'— note CFG block structure (JumpIf, assign blocks).lib/Compiler.php: extendcompileExpr()(or dedicated helper) for the ternary CFG op php-cfg emits afterparseExpr_Ternary()— likely not a singleOp\Expr\*node; trace withbin/print.phpbefore guessing opcode names.TYPE_JUMPIFto true/false blocks → compile each arm → phi/assign merge to target variable (mirrorcompileSwitchStmtblock linking).lib/VM.php: both arms must produce compatible stack types; document mixed string/int behavior vs Zend.lib/JIT.php: LLVM branch +Builder::phiat merge block for SSA values.test/compliance/cases/language/ternary.phpt(string, int, nested); optionaltest/compliance/cases/language/ternary_mixed.phpt.Acceptance criteria
Both print
yes.phpc lintaccepts compliant ternary scripts.Verification (local / Docker only)
Dependencies
??(different opcode path — implement in parallel)Links
lib/Compiler.php,lib/OpCode.php,lib/VM.php,lib/JIT.php