Skip to content

Unexpected behavior with struct multicase unions #1678

@cartermp

Description

@cartermp

The latest F# 4.1 compiler fails to compile either of the following code programs on .NET Core:

[<Struct>]
type Foo = Bar | Baz

[<EntryPoint>]
let main argv =
    printfn "Hello World from F#!"
    0 // return an integer exit code
[<Struct>]
type Foo = 
    | Bar of int
    | Baz of int

[<EntryPoint>]
let main argv =
    printfn "Hello World from F#!"
    0 // return an integer exit code

With this error:

FSC : error FS2014: A problem occurred writing the binary '/Users/phillip/scratch/test/obj/Debug/netcoreapp2.0/test.dll': Error in pass2 for type Program, error: Error in pass2 for type Foo, error: duplicate entry '.ctor' in method table [/Users/phillip/scratch/test/test.fsproj]

This is one rel/2.0.0 of the .NET CLI.

--- Old Issue ---

In VS "15" Preview 5, if you have the following:

[<Struct>]
type Shape =
    | Circle of radius: float
    | Square of side: double
    | Rectangle of sides: double*double

The following error occurs:

Error in pass2 for type Program, error: Error in pass2 for type Shape, error: duplicate entry '.ctor' in method table

If I remove the Square case , or change it to be of type int, it compiles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugImpact-High(Internal MS Team use only) Describes an issue with extreme impact on existing code.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions