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
When opening a namespace that contains a type annotated with [<AutoOpen>], the open is identified as being unused even when the static members of the type are referenced.
From a quick inspection of the code, I would guess this has to do with this guard, which only checks for declarations in namespaces and modules, but not static type members:
namespaceSomeOtherNamespace[<AutoOpen>]typeSomeUnusedType=static membery=1namespaceTestopenSomeOtherNamespacetypeUseTheThings(i:int)=memberx.UseSomeOtherNamespaceTypeMember()= y
When opening a namespace that contains a type annotated with
[<AutoOpen>]
, the open is identified as being unused even when the static members of the type are referenced.Here is a test that triggers the diagnostic: main...joprice:fsharp:autoOpenType
From a quick inspection of the code, I would guess this has to do with this guard, which only checks for declarations in namespaces and modules, but not static type members:
fsharp/src/Compiler/Service/ServiceAnalysis.fs
Line 284 in a7b1303
Expected behavior
Unused open analysis should behave with respect to
[<AutoOpen>]
for types as it does for modules.Actual behavior
The open is marked as unused, even though removing it causes the file to fail to compile.
Known workarounds
Fully qualify the member access.
The text was updated successfully, but these errors were encountered: