dotnet / dotnet/fsharp

Change compiler suggestion when not using return value of a function that returns a `Task`

Open
#18,453 2 comments 0 reactions 0 assignees View on GitHub
Area-Diagnostics Feature Request
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

**Is your feature request related to a problem? Please describe.**

I believe that the F# compiler is providing a wrong suggestion when ignoring (not meaning using `|> ignore`) a result of a function that returns a `Task`. Below is a comparison between C# and F#

`C#`:
![Image](https://github.com/user-attachments/assets/a64a4f71-6515-4c92-869c-58bdb696440a)

`F#`:
![Image](https://github.com/user-attachments/assets/613f2ecb-3766-4856-9140-a191c64d39f3)

The compiler is suggesting a default approach which is to either to pass the result into `ignore` function or to use actual bindings like `let`, which is inherently wrong and must not be suggested, because it is a very rare case, when one actually needs a fire-and-forget operation

**Describe the solution you'd like**

There must be a different suggestion when ignoring a result of Task returning functions. Something like in C#

**Describe alternatives you've considered**

None

**Additional context**

related: #1103

Add any other context or screenshots about the feature request here.

Example wrong behaviour:
![Image](https://github.com/user-attachments/assets/7f2ff4e5-44d7-4f8c-a84e-5c5fb36c97e3)

Example proper behaviour:
![Image](https://github.com/user-attachments/assets/492add12-9687-458c-b3e0-babd1351df1b)

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.