dotnet / dotnet/fsharp

Improve error message when let! _ is last statement in computation expressions

Open
#4,783 7 comments 1 reaction 0 assignees View on GitHub
Area-Diagnostics Feature Improvement Theme-Simple-F#
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

Consider the following code:

let x() = async { return () }

let y =
async {
let! _ = x()
} // compile error - Unexpected symbol }

let z =
async {
do! x()
}

If `x` returns anything else that unit then you can't use `do!` and you have to do:

let y =
async {
let! _ = x()
()
}

This is hard to explain to newcomers - especially given the error mesage.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.