Skip to content

Language: reject catch (Exception $this) as Zend compile fatal (#32204) - #32216

Merged
PurHur merged 2 commits into
masterfrom
agent/issue-32204-catch-this
Aug 18, 2026
Merged

PurHur merged 2 commits into
masterfrom
agent/issue-32204-catch-this

Conversation

@PurHur

@PurHur PurHur commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • catch (Exception $this) is a Zend compile-time fatal (Cannot re-assign $this); this compiler previously accepted the binding and ran (accepted, rc=0).
  • Reject the catch variable in Compiler.php during Op\Stmt\TryCatch lowering, same path as param/global/static $this checks.
  • php-src: Zend/zend_compile.c zend_compile_catch(). PHP: lib/Compiler.php assertNoThisAsCatchVariable(). No new runtime/ C.

Closes #32204

Test plan

  • Issue repro VM + JIT (rc=255, Zend substring, no accepted)
  • ./script/phpunit.sh --filter 'CatchThisCompileFatalTest|CatchThis32204|ReassignThisCompileTest' (13 tests)

Issue repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_catch_this.php'
vm_rc=255
--- stdout ---
--- stderr ---
PHP Fatal error:  Cannot re-assign $this in /compiler/test/repro/maintainer_gap_catch_this.php on line 9
./script/docker-exec.sh -- bash -lc 'php bin/jit.php test/repro/maintainer_gap_catch_this.php'
jit_rc=255
--- stdout ---
--- stderr ---
PHP Fatal error:  Cannot re-assign $this in /compiler/test/repro/maintainer_gap_catch_this.php on line 9

Targeted PHPUnit

./script/phpunit.sh --filter 'CatchThisCompileFatalTest|CatchThis32204|ReassignThisCompileTest'
OK (13 tests, 24 assertions)

Not covered: full VMTest/JITTest suites (not green on master; compare by case name), ci-local.sh, north-star5-verify.

Made with Cursor

PurHur and others added 2 commits August 18, 2026 13:35
php-src zend_compile_catch() fatals Cannot re-assign $this; this compiler
previously accepted the binding and ran. Match param/global/static $this
checks in Compiler.php with a VM/JIT compliance guard.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep both CatchThis32204 and ReservedClassName32206 phpunit entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 3633ba3 into master Aug 18, 2026
@PurHur
PurHur deleted the agent/issue-32204-catch-this branch August 18, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language: catch (Exception $this) compiles — Zend "Cannot re-assign $this" (Zend/zend_compile.c)

1 participant