Repository navigation
fix(explain): retain iteration source across statement boundaries - #991
Merged
Anand Krishnamoorthi (anakrish) merged 1 commit intoNov 24, 2026
Conversation
Reject equal-length recovery candidates spanning statement separators or adjacent operands and signed-number subtraction boundaries. Preserve grouping, keyword operands and valid call/reference continuations, with focused source-location regressions and mutation-proven trailing-operator coverage. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The call exemption misclassifies parentheses after non-callable terms, allowing an incorrect alternative match that loses the iteration’s source text and location.
1 open issue
What changed in this PR
This follow-up to #971 tightens explanation provenance recovery to preserve iteration source text and locations across statement boundaries, without changing policy evaluation or public APIs.
Changes:
- Reject candidate spans that cross statement separators or adjacent operands, and recognize signed-number subtraction continuations.
- Add boundary regressions and controls for grouping, spaced subtraction, and spaced, multiline, and indirect calls.
| File | Description |
|---|---|
src/explain/provenance/tests.rs |
Adds source-text and location regressions plus call-format controls. |
src/explain/provenance.rs |
Strengthens token-boundary checks used to recover iteration expression spans. |
Review effort: Max
| if depth == 0 | ||
| && bracket == 1 | ||
| && follows_operand | ||
| && self.symbol(index) != Some("(") |
Anand Krishnamoorthi (anakrish)
approved these changes
Nov 24, 2026
Anand Krishnamoorthi (anakrish)
merged commit Nov 24, 2026
983dab9
into
microsoft:main
61 checks passed
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
Preserve iteration source text and locations when an equal-length alternative crosses into a following statement.
Reject recovery candidates containing top-level semicolons or adjacent operands, including separate array/set expressions. Treat signed-number tokens as subtraction continuations so candidates cannot stop before an unspaced subtraction. Preserve existing grouping, keyword-shaped operands, references, and spaced, multiline or string-indexed function calls.
Compatibility
Only explanation source metadata changes. No policy evaluation, public API or serialization changes.
Related
Follows #971.
Testing