fsharp
fsharp copied to clipboard
DefaultAugmentation on DU leads to badly generated type
I fell into a pit. exp: Writting a DU in Liberary1:
[<DefaultAugmentation false>] // focus on it
type Bar =
| Test1 of int
| Test 2
module Bar =
let inline foo x = // focus on "inline"
match x with
| Test1 x -> x
| Test2 -> 0
and then write code in Liberary2
let foo2 x = Bar.foo x
As foo2
is called, some exception is happend.
Because DefaultAugmentation false
don't generate property Tag
, the inline function foo
use _tag
for judgment. And when we using Bar.foo
in another liberary, the code inline to foo2
. It visit _tag
, bug it's an internal value...