Skip to content

Language: try/catch/else PHP 8.4 syntax rejected on forward profile (Zend/zend_language_parser.y) #15817

Description

@PurHur

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

  • 8.4 profile: repro prints try then else when no exception; catch path skips else
  • 8.2 reference profile: parse error unchanged
  • Compliance .phpt under test/compliance/cases/language/
  • php-src-strict; no php-compiler-strict shortcut

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions