fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

IsUnionCaseTester throwing an error

Open ncave opened this issue 1 year ago • 13 comments

2 issues with IsUnionCaseTester:

  • Seems to be throwing an error, instead of returning false on non-matching values.
  • Seems to be missing a case where an union case tester method is neither IsProperty nor IsMethod (but it is IsPropertyGetterMethod).

Perhaps it's missing the | V v -> ... case, maybe something like this?

member _.IsUnionCaseTester =
    checkIsResolved()
    match d with
    | P p -> p.IsUnionCaseTester
    | M m -> m.IsUnionCaseTester
    | V v -> v.IsPropertyGetterMethod && v.LogicalName.StartsWith("get_Is") // or something like it
    | E _ | C _ -> false // fixed to return boolean

Related to #16341 Tested on .NET 8.0, with <LangVersion>preview</LangVersion>.

ncave avatar Jun 12 '24 19:06 ncave