Skip to content

Disabling default augmentation for struct DU breaks with .NET 8 #16282

@hyazinthh

Description

@hyazinthh

The compiler shipped with .NET 8.0.100 fails to compile code containing discriminated unions annotated with [<Struct>] and [<DefaultAugmentation(false)>] (error MethodDefNotFound) . Non-struct DUs do not have this problem.

Repro steps

module Test

[<Struct>]
[<DefaultAugmentation(false)>]
type Foo =
    | Baz of int
    | Bar

    member x.IsBaz =
        match x with | Baz _ -> true | _ -> false

    member x.IsBar =
        not x.IsBaz

[<EntryPoint>]
let main argv =
    let foo = Baz 42
    printfn "%A" foo
    0

test.zip

Expected behavior

Should compile.

Actual behavior

Fails with

error FS2014: A problem occurred writing the binary 'D:\test\obj\Debug\net6.0\test.dll': Error in pass3 for type Test, error: Error in GetMethodRefAsMethodDefIdx for mref = ("NewBaz", "Foo"), error: MethodDefNotFound

Related information

  • Windows 10
  • .NET 8.0.100 SDK

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions