Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New codefix provider to remove superflous binding for a Union case that has 0 fields. #14267

Conversation

T-Gro
Copy link
Member

@T-Gro T-Gro commented Nov 8, 2022

This kicks in when:

  • DU case has 0 fields and _ is used to pattern match
  • DU case has 0 fields and a named binding is used to pattern match

This builds on top of the new diagnostics added via #14055

CodeFixRemoveSuperflousBinding.mp4

@T-Gro T-Gro requested a review from a team as a code owner November 8, 2022 13:15
@T-Gro
Copy link
Member Author

T-Gro commented Nov 8, 2022

/run fantomas

@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2022

Failed to run fantomas: https://github.com/dotnet/fsharp/actions/runs/3419732464

@vzarytovskii
Copy link
Member

Huh, interesting that it failed to run fantomas. Need to check what's up with it

@edgarfgp
Copy link
Contributor

edgarfgp commented Nov 8, 2022

@T-Gro This looks awesome .

@kerams
Copy link
Contributor

kerams commented Nov 8, 2022

fsharp/fslang-suggestions#1094 would be a godsend in cases like this.

@T-Gro
Copy link
Member Author

T-Gro commented Nov 8, 2022

fsharp/fslang-suggestions#1094 would be a godsend in cases like this.

Oh yes, the relevant part of the tree when spotting a diagnostic (since it is available "at hand") could directly flow with it.
Right now, doing code fixes feels like scratching your left ear with your right leg :((

@edgarfgp
Copy link
Contributor

@T-Gro While I was adding the same quick fix for Rider. I notice that we can also use the same quick fix for FS3191: This literal pattern does not take arguments

type E =
     | A = 1
     | B = 2

 let (E.A x) = E.A

match E.A with
 | E.A x -> ()

let [<Literal>] A = 1

 match 1 with
 | (A x) -> ()

See JetBrains/resharper-fsharp#444 for more info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants