Skip to content

Add warning FS3885 for let-in with multi-line body in sequence expressions#19501

Draft
Copilot wants to merge 19 commits intomainfrom
copilot/fix-9141961-29048891-3fc9276d-8a02-4a9e-b5d2-cc88eecabc17
Draft

Add warning FS3885 for let-in with multi-line body in sequence expressions#19501
Copilot wants to merge 19 commits intomainfrom
copilot/fix-9141961-29048891-3fc9276d-8a02-4a9e-b5d2-cc88eecabc17

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

Addresses the long-standing issue where let ... in with an explicit in keyword in indentation-sensitive F# code causes the parser to greedily capture all subsequent lines as part of the let body, leading to unexpected scoping behavior.

Following @dsyme's guidance to raise warnings for this formulation, this PR adds a new compiler warning FS3885 gated behind LanguageFeature.WarnOnLetInSequenceExpression (F# 11.0).

Problem

do
    let x = 1 in x + 1
    x  // incorrectly becomes part of the let body

The parser creates LetOrUse(let x = 1, Sequential(x + 1, x)) instead of the expected Sequential(LetOrUse(let x = 1, x + 1), x), causing x on the second line to resolve to the local binding rather than the outer scope.

Changes Made

  • New language feature: Added LanguageFeature.WarnOnLetInSequenceExpression in LanguageFeatures.fs/fsi, gated at F# 11.0
  • Warning FS3885: Added warning message in FSComp.txt that fires when let ... in with an explicit in keyword has a Sequential body extending past the in keyword's line
  • Detection logic: In CheckExpressions.fs, checks trivia.InKeyword = Some inRange and whether the continuation expression starts on a later line than the in keyword
  • Regression tests: 4 tests in WarnExpressionTests.fs covering warning in do blocks, function bodies, no false positives for single-line usage, and no warning on older language versions
  • Release notes: Documented in 11.0.100.md

Testing

  • ✅ All 4 new regression tests pass
  • ✅ All 520 ErrorMessages namespace tests pass
  • ✅ All 630 BasicGrammarElements namespace tests pass
  • ✅ SurfaceAreaTest passes
  • ✅ CodeQL reports no security issues

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

@T-Gro
Copy link
Copy Markdown
Member

T-Gro commented Mar 27, 2026

@copilot : Try again

@T-Gro
Copy link
Copy Markdown
Member

T-Gro commented Mar 27, 2026

@copilot : Try again.

@abonie
Copy link
Copy Markdown
Member

abonie commented Mar 31, 2026

@copilot Try again

Copilot AI and others added 14 commits March 31, 2026 14:52
… element (#19464)

Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
#19341)

Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
* Add Regression PR Shepherd agentic workflow

Shepherds open AI-Issue-Regression-PR pull requests to completion:
- Fixes CI failures and addresses review feedback
- Detects when a test proves the bug still exists (removes label, tags maintainers)
- Runs 6x/day, only touches tests/ files

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

* Add min-integrity: none

* Add min-integrity: none

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
…it, stricter labeling (#19499)

- Enable create-pull-request and push-to-pull-request-branch for regression test PRs
- Enable remove-labels for AI-thinks-issue-fixed and AI-thinks-windows-only
- Add Task 2: Regression Test Verification with adversarial dispute step
- Add Task 3: Systematic revisit of AI-thinks-windows-only claims
- Reorder tasks: Task 1 → Task 3 → Task 2 → FINAL (Task 3 feeds into Task 2)
- Strict windows-only rules with explicit FCS-testable feature list
- Fix memory section to match actual state.json schema
- Remove close-issue actions (closure happens via PR merge with Fixes link)
- Fix stale references, contradictory instructions, date cutoff to 2024
- Clarify anti-spam rules for multi-task commenting

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
…327.7 (#19512)

On relative base path root
Microsoft.DotNet.Arcade.Sdk From Version 10.0.0-beta.26168.1 -> To Version 10.0.0-beta.26177.7

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
* Update dependencies from https://github.com/dotnet/msbuild build 20260324.4
On relative base path root
Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.6.0-preview-26173-02 -> To Version 18.6.0-preview-26174-04

* Update dependencies from https://github.com/dotnet/msbuild build 20260325.1
On relative base path root
Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.6.0-preview-26173-02 -> To Version 18.6.0-preview-26175-01

* Update dependencies from https://github.com/dotnet/msbuild build 20260326.1
On relative base path root
Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.6.0-preview-26173-02 -> To Version 18.6.0-preview-26176-01

* Update dependencies from https://github.com/dotnet/msbuild build 20260327.2
On relative base path root
Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.6.0-preview-26173-02 -> To Version 18.6.0-preview-26177-02

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
…f`1 (#19485)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
…#19480)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
* Add regression test for #13519: C# optional parameters from F#

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

* Add ParamArray + optional params regression test for #13519

Addresses reviewer feedback: the original issue was specifically about
the intersection of omitted optional arguments and ParamArray arguments,
as identified by Don Syme. This adds a test covering that exact scenario.

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

---------

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

* Add regression test for #6648: DU of DUs with inline static members

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

* Fix unclosed triple-quoted string in Issue 6648 regression test

Add missing closing triple-quote and assertion pipeline to the
DU of DUs with inline static members test.

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
)

* Initial plan

* Fix repo-assist: add safe output discipline, iteration limits, and noop fallback

Root cause: Agent spent ~37 minutes creating ~25 test files across 5+ issues
without calling any safe output MCP tools, resulting in empty agent_output.json.

- Add "Safe Output Discipline" section with incremental output, noop fallback,
  3-attempt iteration limit per issue, and time awareness rules
- Task 1: call safe output tools immediately after each issue
- Task 2: limit build-and-test cycles to 3 per issue, create PRs immediately,
  do not create multiple test file variants

Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/cf589816-f234-44e2-9245-742907ee5d27

Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>

* Run gh aw upgrade and gh aw compile to regenerate lock files

Updates gh-aw from v0.64.2 to v0.64.4:
- Regenerate repo-assist.lock.yml with new frontmatter hash
- Regenerate regression-pr-shepherd.lock.yml
- Update actions-lock.json with new action SHAs
- Update agentic-workflows.agent.md version references

Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/0f6b9ce7-da31-403c-b633-6bb5f004484e

Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Co-authored-by: Tomas Grosup <Tomas.Grosup@gmail.com>
Co-authored-by: Adam Boniecki <20281641+abonie@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
…0330.8 (#19525)

On relative base path root
Microsoft.Build , Microsoft.Build.Framework , Microsoft.Build.Tasks.Core , Microsoft.Build.Utilities.Core From Version 18.6.0-preview-26177-02 -> To Version 18.6.0-preview-26180-08

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
…otnet-optimization build 20260330.1 (#19523)

On relative base path root
optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime From Version 1.0.0-prerelease.26153.1 -> To Version 1.0.0-prerelease.26180.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
T-Gro and others added 4 commits March 31, 2026 14:52
* Add aw-auto-update workflow for daily gh aw upgrade/compile

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

* Update agentic workflows via gh aw upgrade (v0.64.2 → v0.64.4)

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
Verifies that land, lor, lxor, lsl, lsr, and asr can be used as valid
identifiers after the ML compatibility removal in PR #19143.

Fixes #6715

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/740bb677-5347-48ad-9001-278dfc1631e3

Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 31, 2026

@copilot Try again

Implemented in 4c00982 and 6259b63. Added warning FS3885 (gated behind LanguageFeature.WarnOnLetInSequenceExpression at F# 11.0) that fires when let ... in with an explicit in keyword has a body that extends to subsequent lines — the common pitfall from issue #7091 where the parser greedily captures all subsequent lines as part of the let body.

Changes:

  • New LanguageFeature.WarnOnLetInSequenceExpression in LanguageFeatures.fs/fsi
  • Warning FS3885 message in FSComp.txt
  • Detection in CheckExpressions.fs: checks for explicit in keyword + Sequential body extending past the in line
  • 4 regression tests (warning in do block, warning in function body, no warning for single-line let-in, no warning without preview langversion)
  • Release notes

All 520 ErrorMessages tests and 630 BasicGrammar tests pass.

Copilot AI changed the title [WIP] Copilot Request Add warning FS3885 for let-in with multi-line body in sequence expressions Mar 31, 2026
Copilot AI requested a review from abonie March 31, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

3 participants