The plain answer is, do so:
if (x :> obj) :? Test then printfn "true" else printfn "false"
This issue comes because of the implementation of DUs (using internal classes and tags) and the limitation of F#'s type system (which does not acknowledge the implementation).
As you saw, the type of x
is FSI_0001+Test+Age
, and F# does not recognize that as a sub-type of Test
.