VM: fix run-stack push for nested return <call>() (#1885) - #1910
Merged
Merged
Conversation
Context::push() used a chained assignment that wired the new entry as main.prev instead of the stack top, so nested calls lost the caller frame and returns never resumed main (empty PHPT output). Also stop nulling returnVar on TYPE_RETURN_VOID when it aliases the caller's result slot, and resolve indirect values on TYPE_RETURN. Compiler slot-reuse from #1885 remains; late_static_binding.phpt passes. Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced May 25, 2026
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
PR #1897 landed compiler slot reuse for
return <call>(), but nested returns still produced empty output becauseContext::push()used a broken chained assignment:That attached the new entry as
main.previnstead of the stack top, so the caller frame was lost after the first nested call andlate_static_binding.phptstayed empty.This PR fixes
push()to chain entries correctly, stops clearingreturnVaronTYPE_RETURN_VOIDwhen it may alias the caller slot, and resolves indirect values onTYPE_RETURN.Test plan
NestedReturnVmTest(nestedreturn f(), void inner call + return, late staticreturn static::tag())VMTestlate_static_bindingcompliance PHPTphp-compiler:22.04-dev(no GHA)Follow-up to merged #1897; completes #1885 on master.
Made with Cursor