Language: builtin Exception/Error/Throwable VM classes (#195) - #3215
Merged
Merged
Conversation
This was referenced May 29, 2026
PurHur
force-pushed
the
agent/issue-195-exception-classes
branch
3 times, most recently
from
May 30, 2026 18:27
3c8fb9a to
643e6ff
Compare
Owner
Author
|
Worker lane A (continuation): Rebased onto latest master and re-verified. Verification (May 2026)./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r '"'"'try { throw new Exception("x"); } catch (Exception $e) { echo $e->getMessage(); }'"'"''
# x
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit test/unit/ExceptionBuiltinTest.php test/compliance/VMTest.php --filter exception'
# OK (7 tests)Master without this patch still fails with |
Owner
Author
Update (cursor-agent-lane-a)Added Zend getLine() parity for rethrow and deferred throw paths:
New compliance: VerificationPHP_COMPILER_CI_SINGLE_CONTAINER=0 ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit test/unit/ExceptionBuiltinTest.php test/unit/TryCatchComplianceTest.php test/compliance/VMTest.php --filter exception_throw'
# OK (24 tests)php-src: |
PurHur
added a commit
that referenced
this pull request
May 31, 2026
Add ExceptionBuiltinTest subprocess coverage matching compliance PHPTs; Runtime-only unit tests pass on master while stdin VM CLI still fails with merge resume frame setup until #3215 lands. php-src: Zend/zend_exceptions.c (catch frame + merge resume) Co-authored-by: Cursor <cursoragent@cursor.com>
Set inheritUndefinedLocals on the try/catch merge block so enterMatchingCatchHandler can build the merge resume frame without "Could not resolve argument" when dispatching from TYPE_THROW into a catch handler. php-src: Zend/zend_exceptions.c (catch frame + finally/merge resume) Co-authored-by: Cursor <cursoragent@cursor.com>
Record php-cfg startLine on TYPE_THROW arg2 and update the exception object at throw time so getLine() matches Zend for caught throws. php-src: Zend/zend_exceptions.c (zend_exception_set_previous) Co-authored-by: Cursor <cursoragent@cursor.com>
Guards throw-site line stamping (TYPE_THROW arg2) and file path on caught Exception objects per Zend zend_exceptions.c parity. Co-authored-by: Cursor <cursoragent@cursor.com>
…195) Record new-expression startLine on TYPE_NEW for Throwable objects and only stamp TYPE_THROW line when still unset (Zend zend_exceptions.c parity). Register catch variables on catch-body blocks so throw $e works without a prior read in nested try handlers. php-src: Zend/zend_exceptions.c Co-authored-by: Cursor <cursoragent@cursor.com>
Add ExceptionBuiltinTest subprocess coverage matching compliance PHPTs; Runtime-only unit tests pass on master while stdin VM CLI still fails with merge resume frame setup until #3215 lands. php-src: Zend/zend_exceptions.c (catch frame + merge resume) Co-authored-by: Cursor <cursoragent@cursor.com>
Add compliance PHPT and unit test for merge-block resume when the catch body contains an inner try/catch before using the caught exception. Co-authored-by: Cursor <cursoragent@cursor.com>
…lly block (#195) When a catch body references \$e, php-cfg merge lowering incorrectly registers \$e as a finally-block inherited arg. Finally runs before catch on throw, so getFrame failed with "Could not resolve argument". Mark the finally CFG block inheritUndefinedLocals so catch locals are not required during finally dispatch. Adds compliance PHPT and unit test for try/catch/finally with getMessage(). php-src: Zend/zend_exceptions.c — finally-before-catch unwind order Co-authored-by: Cursor <cursoragent@cursor.com>
On matching catch, run the catch body before finally (php-src zend_exceptions.c). Unmatched throws still run finally before propagating. Fixes PHPT/unit expectations. Co-authored-by: Cursor <cursoragent@cursor.com>
Update testFinallyRunsBeforeCatchOnThrow expectation to match Zend zend_exceptions.c order (catch body before finally on matched throw). Co-authored-by: Cursor <cursoragent@cursor.com>
PurHur
force-pushed
the
agent/issue-195-exception-classes
branch
from
May 31, 2026 09:43
7fd1971 to
b372531
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rebased on master (May 2026): builtin
Throwable/Exception/Errorhierarchy is already registered via #3371. This PR closes the remaining #195 gap — catch-variable use after merge resume.inheritUndefinedLocalson the try/catch merge block soenterMatchingCatchHandlercan build the post-catch resume frame withoutCould not resolve argumentwhen the catch body uses$e->getMessage()(etc.).php-src reference
Zend/zend_exceptions.c— catch frame setup + merge/finally resume control flowVerification
All green on rebased branch.
Closes #195