fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

`open type T` when `T` is an enum is treated as unused even when it's used

Open brianrourkeboll opened this issue 1 year ago • 1 comments

Repro steps

// Shows as unused; the unused opens analyzer will suggest removing it.
open type System.DayOfWeek

// …Even though it's used.
let monday = Monday

Expected behavior

The open type declaration for an enum should be considered used if any of its enum cases are used unqualified.

Actual behavior

The open type declaration for an enum is considered unused even when one or more of its enum cases are used.

Known workarounds

N/A.

Related information

.NET 8, 9.

brianrourkeboll avatar Aug 27 '24 22:08 brianrourkeboll

I assume the fix involves yielding the enum cases as FSharpSymbols in here:

https://github.com/dotnet/fsharp/blob/6c96fc7065b178ca0a587d606e9eae3f1380a5b6/src/Compiler/Service/ServiceAnalysis.fs#L23-L54

brianrourkeboll avatar Aug 27 '24 22:08 brianrourkeboll