Skip to content

Warning 20 range: also walk through let/use bindings (follow-up to #19504)#19896

Merged
T-Gro merged 10 commits into
mainfrom
copilot/fix-warning-20-let-binding-range
Jun 23, 2026
Merged

Warning 20 range: also walk through let/use bindings (follow-up to #19504)#19896
T-Gro merged 10 commits into
mainfrom
copilot/fix-warning-20-let-binding-range

Conversation

@T-Gro

@T-Gro T-Gro commented Jun 5, 2026

Copy link
Copy Markdown
Member

Follow-up to #19504 addressing review feedback from @auduchinok.

#19504 fixed warning 20 ("expression is implicitly ignored") to point at the last expression of a sequential body inside for/while. The walk only descended through SynExpr.Sequential, so when the last expression was the body of a let/use binding, the squiggle covered the whole let expression instead of just the offending tail:

for _ in [] do
    let x = 1   // \
    x           //  > squiggle spanned both lines (from `let` to end of `x`)

This PR also descends through SynExpr.LetOrUse, so the squiggle lands on x alone in cases like the one above.

It also corrects the issue reference cited by the original PR (#5418 — "Wrong expression is ignored warning range"; the previously cited #5735 is unrelated to this diagnostic).

Tracking: #5418

- Walk through let/use bindings in addition to Sequential when locating
  the offending expression for warning 20. Fixes the case Eugene flagged:
    for _ in [] do
        let x = 1
        x
- Fix wrong issue link (#5735 -> #5418) in code comment, release notes,
  and test annotations.
- Add regression tests for the let/use case (single + nested bindings).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.100.md

@github-actions github-actions Bot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label Jun 5, 2026
@T-Gro T-Gro requested a review from abonie June 5, 2026 09:49
@T-Gro T-Gro enabled auto-merge (squash) June 5, 2026 09:49

@abonie abonie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI-generated review — verify before acting on findings.

@abonie abonie added the AI-reviewed PR reviewed by AI review council label Jun 8, 2026
@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling Jun 8, 2026
Comment thread src/Compiler/Checking/Expressions/CheckExpressions.fs Outdated
Comment thread tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs Outdated
Copilot and others added 4 commits June 12, 2026 12:34
… add PR link

- Remove issue URL references from code comments and test methods
  (per auduchinok: redundant, commit links to PR with full context)
- Add test for 'use' binding (non-unit after use)
- Add test for computation expression after let binding
- Add PR #19896 link to release notes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dy covers the user-facing fix

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread tests/FSharp.Compiler.ComponentTests/ErrorMessages/WarnExpressionTests.fs Outdated
T-Gro and others added 5 commits June 12, 2026 13:57
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The CI check requires a release notes entry referencing this PR's URL.
Also corrects the issue reference from #5735 to #5418 in the existing
warning 20 entry (per review feedback on PR #19504).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The previous 'computation expression after let binding' test only used
async { return x } as a non-unit value - it didn't exercise CE-specific
syntax constructs. Replace with a while-loop test that genuinely exercises
the TcStmt lastExprRange fix in a different loop context.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@T-Gro T-Gro requested a review from abonie June 23, 2026 13:16
@T-Gro T-Gro merged commit 1c73b9a into main Jun 23, 2026
57 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in F# Compiler and Tooling Jun 23, 2026
@T-Gro T-Gro deleted the copilot/fix-warning-20-let-binding-range branch June 24, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-reviewed PR reviewed by AI review council AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants