Confusing/incorrect type mismatch message in async CE
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 144
Description
Consider this code (type annotations added for clarity):
```f#
async {
let asyncUnitArr : Async = async.Return [| () |]
do! asyncUnitArr
}
```
It fails to compile with this message on the second `asyncUnitArr`:
> This expression was expected to have type 'unit[]' but here has type 'unit'

I find this confusing for two reasons.
Firstly, the expression that is underlined, `asyncUnitArr`, has the type `Async`, so the message seems to be missing the `Async` wrapper.
Secondly, the wording/types seem to be switched around. The expression _has_ the type `Async` and (given the context) is _expected_ to have the type `Async`.
For comparison, here is a similar error message that seems to be correct:
```f#
let f (x: int) = ()
f ""
```

Contributor guide
Assessment
This issue has not been assessed yet.