Fix #19457: lift CE constructs from plain let RHS in computation expressions#19868
Open
T-Gro wants to merge 4 commits into
Open
Fix #19457: lift CE constructs from plain let RHS in computation expressions#19868T-Gro wants to merge 4 commits into
T-Gro wants to merge 4 commits into
Conversation
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>
Contributor
❗ Release notes required
|
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
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
Testing