Skip to content

Fix #19457: lift CE constructs from plain let RHS in computation expressions#19868

Open
T-Gro wants to merge 4 commits into
mainfrom
fix/issue-19457
Open

Fix #19457: lift CE constructs from plain let RHS in computation expressions#19868
T-Gro wants to merge 4 commits into
mainfrom
fix/issue-19457

Conversation

@T-Gro
Copy link
Copy Markdown
Member

@T-Gro T-Gro commented May 29, 2026

Summary

Fixes #19457

When a plain let p = rhs in body appears inside a computation expression, and
hs itself contains CE-only constructs (e.g. let! x = ...; x or do! ...; rest), the compiler incorrectly raised FS0750 ("This construct may only be used within computation expressions").

Fix

Rewrite the expression so those CE constructs are lifted into the enclosing CE, where they desugar correctly. This makes examples like:

\\ sharp
task {
let result =
let! x = someAsync
x + 1
return result
}
\\

compile as expected.

Changes

  • CheckComputationExpressions.fs: Added logic to detect and lift CE-only constructs from the RHS of plain let bindings inside CEs.
  • ComputationExpressionTests.fs: Added tests covering nested let!/do! in plain let bindings within CEs.
  • Release notes: Entry added to docs/release-notes/.FSharp.Compiler.Service/11.0.100.md.

Testing

  • All new tests pass (ComponentTests Release: 13922 passed, 0 failed)
  • SurfaceAreaTest passes (no public API change)
  • Fantomas formatting check passes

Copilot and others added 3 commits May 29, 2026 18:31
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a plain 'let p = rhs in body' appears inside a computation expression,
and 'rhs' itself is a chain of CE-only constructs (e.g. 'let! x = ...; x'
or 'do! ...; rest'), rewrite the expression so those constructs are
lifted into the enclosing CE, where they desugar correctly. This makes the
example from issue #19457 compile.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Verification-only sprint:
- fantomas --check clean on CheckComputationExpressions.fs and ComputationExpressionTests.fs
- release notes entry for #19457 already added in Sprint 03 (docs/release-notes/.FSharp.Compiler.Service/11.0.100.md)
- ComponentTests Release: 13922 passed, 0 failed, 775 skipped
- SurfaceAreaTest on net10.0: passed (no public API surface change)
- PR description draft at .tools/ralph/pr_description.md

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

github-actions Bot commented May 29, 2026

❗ Release notes required


✅ 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-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files label May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-Scanned-Clean Tooling check: diff analyzed, no interesting infrastructure files

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Nested let! should compile

1 participant