dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.94k stars 789 forks source link

Quick fix to add missing pattern matching #2886

Open Thorium opened 7 years ago

Thorium commented 7 years ago

Suggestion to code editor quick fixes:

example

When matching over enum or discriminated union type, and gotten warning "Incomplete pattern matches", provide a quick hint fix possibility to add missing enums.

kerams commented 2 years ago

I'd say this should be fairly easy to achieve when you don't have any clauses typed out yet. Finding out the missing cases can otherwise be very tricky, what with active patterns, when guards, subpatterns... Yes, the compiler will (always?) give you an example of something that's not covered, but I'm not sure it's viable for it to provide an exhaustive list of missing cases.

psfinaki commented 1 year ago

Good point @kerams. We could probably have this only for simple cases like type DU = | A | B | C.