dotnet / dotnet/fsharp

Discriminated union .Is* properties causing compile time error

Open
#18,263 7 comments 0 reactions 1 assignee Claimed by @psfinaki View on GitHub
Area-Compiler-CodeGen Bug Impact-High
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

Compile time error since Visual Studio update: "Error in pass2 for type Foo, error: duplicate entry 'get_IsSZ' in method table."

**Repro steps**

Create blank F# class library

```
namespace FSharpClassLibrary4

module Say =
let hello name =
printfn "Hello %s" name

type Foo =
| SZ
| STZ
| ZS
| ASZ
```

**Expected behavior**

The example compiles successfully.

**Actual behavior**

Compile time error:
"A problem occurred writing the binary 'C:\...\FSharpClassLibrary4\FSharpClassLibrary4\obj\Debug\net6.0\FSharpClassLibrary4.dll': Error in pass2 for type FSharpClassLibrary4.Say, error: Error in pass2 for type Foo, error: duplicate entry 'get_IsSZ' in method table"

**Known workarounds**

1. Use Language version 8
2. Rename SZ type not to begin with SZ

**Related information**

.NET SDK: 9.0.102
Visual Studio: 17.12.4

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.