fsharp
fsharp copied to clipboard
Module import is considered unused if it used only for an extension method used in a CE
Repro steps Consider the following code:
open System.Threading.Tasks
module Builder =
type AsyncBuilder with
// allows to bind to the result of Tasks
member _.Bind (task : Task<'a>, cont : 'a -> Async<'b>) =
async.Bind (Async.AwaitTask task, cont)
open Builder
let task = Task.FromResult 1
let x = async {
let! i = task
return i + 1
}
Here the Builder
module contains an extension method for an AsyncBuilder
that enables the former to bind to the results of usual .Net tasks.
Expected behavior
No compiler warnings or errors.
Actual behavior
F# compiler considers this import to be not required: Warning "IDE0005: Open declaration can be removed".
But it is required as without it the compiler generates an error:
X.fs(16, 14): [FS0001] This expression was expected to have type
'Async<'a>'
but here has type
'Task<int>'
Related information
- Operating system — Windows 10
- .NET Framework 4.7.2
- Visual Studio 16.10.0