Category
language · php-src-strict · PHP 8.4 forward profile
Problem
PHP 8.4 added try { } catch () { } else { } — the else block runs when no exception was thrown. On PHP_COMPILER_PROFILE=8.4, this compiler still rejects the syntax at parse time (Syntax error, unexpected T_ELSE), while property hooks and other 8.4 features compile on the same profile.
| Repro |
Zend 8.4 |
VM 8.4 profile (2026-07-04) |
try { echo "try\n"; } catch (Throwable) { } else { echo "else\n"; } |
try + else lines |
Parse error on else |
On Zend/VM 8.2 reference profile, both correctly reject the syntax — parity holds there; fix must enable parsing/lowering only when the language profile is 8.4+.
php-src reference
PHP implementation target
lib/Compiler.php / nikic/php-parser upgrade path — parse Stmt\TryCatch with optional else array
lib/VM.php — emit else block only when catch handlers did not run; PHP lowering only
Repro
./script/docker-exec.sh -- bash -lc 'PHP_COMPILER_PROFILE=8.4 php bin/vm.php test/repro/maintainer_gap_try_catch_else.php'
PHP_COMPILER_PROFILE=8.4 php test/repro/maintainer_gap_try_catch_else.php
Done when
Category
language· php-src-strict · PHP 8.4 forward profileProblem
PHP 8.4 added
try { } catch () { } else { }— theelseblock runs when no exception was thrown. OnPHP_COMPILER_PROFILE=8.4, this compiler still rejects the syntax at parse time (Syntax error, unexpected T_ELSE), while property hooks and other 8.4 features compile on the same profile.try { echo "try\n"; } catch (Throwable) { } else { echo "else\n"; }try+elselineselseOn Zend/VM 8.2 reference profile, both correctly reject the syntax — parity holds there; fix must enable parsing/lowering only when the language profile is 8.4+.
php-src reference
Zend/zend_language_parser.y—try_catch_list elseZend/zend_compile.c—zend_compile_tryelse branchPHP implementation target
lib/Compiler.php/ nikic/php-parser upgrade path — parseStmt\TryCatchwith optionalelsearraylib/VM.php— emit else block only when catch handlers did not run; PHP lowering onlyRepro
./script/docker-exec.sh -- bash -lc 'PHP_COMPILER_PROFILE=8.4 php bin/vm.php test/repro/maintainer_gap_try_catch_else.php' PHP_COMPILER_PROFILE=8.4 php test/repro/maintainer_gap_try_catch_else.phpDone when
trythenelsewhen no exception; catch path skips else.phptundertest/compliance/cases/language/