Category
language
Problem
PHP 8.0 throw expressions allow throw anywhere an expression is valid (ternary arms, null-coalesce, short-circuit, parentheses). This compiler’s php-cfg pass does not handle PhpParser\Node\Expr\Throw_ inside expression trees — parse fails before compile.
This is syntax/lowering, distinct from #195 (builtin Exception class registration for catch).
php-src reference
Repro (failure today)
<?php
// ternary arm
echo (false ? 1 : throw new LogicException('x'));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
Zend PHP 8+: uncaught LogicException: x (non-zero exit)
This compiler:
RuntimeException: Unknown Expr Type Expr_Throw
in vendor/ircmaxell/php-cfg/lib/PHPCfg/Parser.php
Also fails for: ($x ?? throw new Exception('missing')), true && throw new Exception('x').
Scope (this repo)
| Layer |
Path |
Notes |
| php-cfg |
vendor/ircmaxell/php-cfg/lib/PHPCfg/Parser.php |
parseExprNode() / parseExpr_Throw |
| Patch |
patches/php-cfg-*.patch |
if vendor fix required |
| Compiler |
lib/Compiler.php |
lower throw-expr to TYPE_THROW with value operand |
| VM/JIT |
lib/VM.php, lib/JIT.php |
reuse existing throw opcodes |
| Tests |
test/compliance/cases/language/throw_expression.phpt |
ternary + coalesce cases |
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./script/ci-fast.sh --filter throw_expression'
Dependencies
Links
Category
languageProblem
PHP 8.0 throw expressions allow
throwanywhere an expression is valid (ternary arms, null-coalesce, short-circuit, parentheses). This compiler’s php-cfg pass does not handlePhpParser\Node\Expr\Throw_inside expression trees — parse fails before compile.This is syntax/lowering, distinct from #195 (builtin
Exceptionclass registration forcatch).php-src reference
Zend/zend_compile.c—zend_compile_throw()used from expression compile pathsZend/zend_language_parser.y—exprincludesT_THROW exprRepro (failure today)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'Zend PHP 8+: uncaught
LogicException: x(non-zero exit)This compiler:
Also fails for:
($x ?? throw new Exception('missing')),true && throw new Exception('x').Scope (this repo)
vendor/ircmaxell/php-cfg/lib/PHPCfg/Parser.phpparseExprNode()/parseExpr_Throwpatches/php-cfg-*.patchlib/Compiler.phpTYPE_THROWwith value operandlib/VM.php,lib/JIT.phptest/compliance/cases/language/throw_expression.phptDone when
LogicExceptionor user class)&&/\|\|throw arm matches Zend evaluation order./script/ci-fast.sh --filter throw_expressiongreendocs/capabilities-syntax.mdnotes throw-expressions VM/JIT/AOT statusVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./script/ci-fast.sh --filter throw_expression'Dependencies
Exception/LogicException(can land parser first with user classes)Links