-
Notifications
You must be signed in to change notification settings - Fork 853
Open
Labels
Area-ComputationExpressionsEnd-to-end experience for computation expressions (except async and state machine compilation)End-to-end experience for computation expressions (except async and state machine compilation)Bug
Milestone
Description
A let! nested in a simple let binding is currently not allowed by the compiler.
Example:
let y() =
task {
let a =
let! b = System.IO.File.ReadAllLinesAsync("")
b
return a
}
The 4th line produces error FS0750: This construct may only be used within computation expressions.
(Except for SDK 10.0, where the let! is silently compiled as a simple let, see #19456.)
I believe this behavior is a bug and the above example should compile correctly.
The spec, as quoted here, prescribes the following transformations:
{{ let binding in cexpr }} => let binding in {{ cexpr }} and
{{ let! pattern = expr in cexpr }} => builder.Bind(expr, (fun pattern -> {{ cexpr }}))
It seems that applying them to the example code is straightforward and should lead to correct compilation of the CE rather than to an error message.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-ComputationExpressionsEnd-to-end experience for computation expressions (except async and state machine compilation)End-to-end experience for computation expressions (except async and state machine compilation)Bug
Type
Projects
Status
New