You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Module import is considered unused if it used only for an extension method used in a CE #11626
openSystem.Threading.TasksmoduleBuilder =typeAsyncBuilderwith// allows to bind to the result of Tasksmember_.Bind(task :Task<'a>,cont :'a ->Async<'b>)=
async.Bind (Async.AwaitTask task, cont)openBuilderlettask= Task.FromResult 1letx=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>'
The type checker records resolved symbols for future use in features like identifier highlighting and Find Usages. IIRC the results of resolving of builders members are not recorded in any way.
The analyzer goes over the resolved symbols and tries to find and mark an open that a symbol could come from, and since symbols used in let! are not recorded, they don't mark the corresponding opens as used.
Ideally, opens should be marked during the type check (it could also fix some corner cases related to shadowing of imported symbols), but that's not how it's currently done and would probably require a big refactoring of the symbols import/resolve logic.
A somewhat hacky fix could be recording the builder members like let! usages with some special occurrence kind, so they could be used in open analysis while not being highlighted as methods, thanks to a special occurrence kind check. This would add a small overhead, since we'll keep more resolved symbols, but it'll likely be really small compared to all the rest symbols in files we already keep.
A related issue is the build methods are also considered unused, even though that's not really the case. The builder method stuff could get fixed pretty easily, I had a hacky approach for dealing with that here: #9736 it can probably be re-opened.
Correction: My previous comment was incorrect. I tested with --warnon:1182 --warnaserror:1182 which only covers unused bindings (FS1182), not unused opens. The unused opens analysis is a separate FCS feature (UnusedOpens.getUnusedOpens).
Verified with the FCS API (F# 11.0, commit 39cadd93b): UnusedOpens.getUnusedOpensstill reports open Builder as unused, confirming this issue is not fixed.
Activity
auduchinok commentedon Jun 4, 2021
The type checker records resolved symbols for future use in features like identifier highlighting and Find Usages. IIRC the results of resolving of builders members are not recorded in any way.
The analyzer goes over the resolved symbols and tries to find and mark an
openthat a symbol could come from, and since symbols used inlet!are not recorded, they don't mark the correspondingopens as used.Ideally,
opens should be marked during the type check (it could also fix some corner cases related to shadowing of imported symbols), but that's not how it's currently done and would probably require a big refactoring of the symbols import/resolve logic.A somewhat hacky fix could be recording the builder members like
let!usages with some special occurrence kind, so they could be used inopenanalysis while not being highlighted as methods, thanks to a special occurrence kind check. This would add a small overhead, since we'll keep more resolved symbols, but it'll likely be really small compared to all the rest symbols in files we already keep.cartermp commentedon Jun 4, 2021
A related issue is the build methods are also considered unused, even though that's not really the case. The builder method stuff could get fixed pretty easily, I had a hacky approach for dealing with that here: #9736 it can probably be re-opened.
I like @auduchinok's idea for the builder
open.github-actions commentedon Apr 20, 2026
github-actions commentedon Apr 20, 2026
🤖 This is an automated response from Repo Assist.
Correction: My previous comment was incorrect. I tested with
--warnon:1182 --warnaserror:1182which only covers unused bindings (FS1182), not unused opens. The unused opens analysis is a separate FCS feature (UnusedOpens.getUnusedOpens).Verified with the FCS API (F# 11.0, commit
39cadd93b):UnusedOpens.getUnusedOpensstill reportsopen Builderas unused, confirming this issue is not fixed.The
AI-thinks-issue-fixedlabel has been removed. Apologies for the false positive.