Fix ASM frame crash when range operator RHS is a constant sub#297
Merged
Fix ASM frame crash when range operator RHS is a constant sub#297
Conversation
The range operator (..) was not spilling its left operand before evaluating the right side. When the RHS was a constant sub call (e.g., @A[0..CONST]), the non-local control flow handling could leave the JVM operand stack in an inconsistent state, causing "Incompatible stack heights" errors during ASM frame computation. Fix: Apply the same spill pattern used by other binary operators (substr, concat, push, etc.) - store LHS in a local variable before evaluating RHS, then restore it. Reproducer: use constant END => 2; sub test { my @A = (1,2,3,4); return @A[0..END]; } Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
fglock
added a commit
that referenced
this pull request
Mar 10, 2026
Follow-up to PR #297: Apply the same spill pattern to additional operators that were missing it: - atan2 function - e.g., atan2(0, CONST) - exists/delete with compound dereference - e.g., exists $h{key}[CONST] These operators were not spilling their left operand before evaluating the right side, causing "Incompatible stack heights" errors when the RHS was a constant sub call. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
3 tasks
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
Fixes ASM frame computation crash when using array slices with constants as range endpoints.
Reproducer:
Root cause: The range operator (..) was not spilling its left operand before evaluating the right side. When the RHS was a constant sub call, the non-local control flow handling could leave the JVM operand stack in an inconsistent state.
Fix: Apply the same spill pattern used by other binary operators (substr, concat, push, etc.).
Test plan
Generated with Devin