Don't let append overwrite sibling results in tspath.GetCommonParents - #64493
Merged
Jake Bailey (jakebailey) merged 2 commits intoSep 29, 2026
Merged
Jake Bailey (jakebailey) merged 2 commits into
Jake Bailey (jakebailey) merged 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused allocation fix addresses the reported corruption and is covered by a suitable regression test.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes backing-array aliasing in GetCommonParents, preventing sibling path results from overwriting one another.
Changes:
- Uses
slices.Concatto create independent result slices. - Adds a nested fan-out regression test.
| File | Description |
|---|---|
tsc/internal/tspath/path.go |
Prevents result slices from sharing mutable backing storage. |
tsc/internal/tspath/path_test.go |
Verifies all nested fan-out results are retained. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Jake Bailey (jakebailey)
approved these changes
Sep 29, 2026
Copilot started reviewing on behalf of
Jake Bailey (jakebailey)
September 29, 2026 07:27
View session
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.
Fixes #64492
Cause:
group.headis a subslice of an input path's components that still has spare capacity, so when a group has more than one sub-result, they overwrite each other in the shared backing array. One directory comes out twice (or as a nonexistent path), and another is dropped.