Skip to content

Instantly share code, notes, and snippets.

@alex-ilin
Created August 16, 2022 14:41
Show Gist options
  • Save alex-ilin/abdc9a81a4428c7efdd9c2d2a7407d5d to your computer and use it in GitHub Desktop.
Save alex-ilin/abdc9a81a4428c7efdd9c2d2a7407d5d to your computer and use it in GitHub Desktop.
F# Warning FS0049 when catching an exception class
type SitAction = { Rest: int }
type StandAction = { Rest: int }
type Action =
| Stand of StandAction
| Sit of SitAction
let lastStandIndex (x: Action list) : int option =
try
x |> List.tryFindIndex (function
| Stand _ -> true
| _ -> false)
with
| KeyNotFoundException -> None
// Warning FS0049: Uppercase variable identifiers should not generally be used in patterns,
// and may indicate a missing open declaration or a misspelt pattern name.
// How do I avoid this warning without suppressing it?
// I tried using the full name System.Collections.Generic.KeyNotFoundException, but that would not compile.
@alex-ilin
Copy link
Author

Perfect, thank you!
(I have left out the as ex part, since I'm not going to use the identifier.)

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