Skip to content

unused open when AutoOpen used on type with static members #17929

@joprice

Description

@joprice

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:

| Some entity when entity.IsNamespace || entity.IsFSharpModule ->

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions