Module import is considered unused if it used only for an extension method used in a CE
- Lingua principale
- F#
- Stelle
- 4.3k
- Fork
- 877
- Merge medio
- 5g 11h
- PR unite (30g)
- 153
Descrizione
**Repro steps**
Consider the following code:
```fsharp
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'
```
**Related information**
* Operating system — Windows 10
* .NET Framework 4.7.2
* Visual Studio 16.10.0
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia riproducendo il codice F# mostrato nell’issue e confronta l’avviso IDE0005 con l’errore del compilatore dopo aver rimosso `open Builder`. Traccia il modo in cui l’uso dei metodi di estensione all’interno della computation expression viene considerato dall’analisi degli open inutilizzati. Il lavoro è terminato quando l’import richiesto non viene segnalato come rimovibile e la computation expression continua a essere verificata correttamente dal sistema dei tipi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- fsharp
- Ambito
- compilers, tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 52/100