You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Discriminated union .Is* properties causing compile time error #18263
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"
Do you by any chance have a Directory.props or Directory.targets in the folder hiearchy?
I tried a dotnet build of the project and it passes at me.
I also enforced the SDK via an added global.json file to be "version": "9.0.102" and it also passes.
Among others, your file specified a net9 target framework, but the error message below does have net6.0 in it - which gives me the idea of some parent folder affecting msbuild properties perharps?
I can successfully compile the project with dotnet build too.
If I try msbuild from a Developer Command prompt, I get the same error: "FSC : error FS2014: A problem occurred writing the binary 'obj\Debug\net9.0\refint\FSharpClassLibrary4.dll': Error in pass2 for type FSharpClassLibrary4.Say, error: Error in pass2 for type Foo, error: duplicate entry 'get_IsSZ' in method table [c:...\FSharpClassLibrary4\FSharpClassLibrary4\FSharpClassLibrary4.fsproj]"
I tried a lot of SDK and .NET version and I don't remember where I copied that error message (net6.0) from.
17.12 had an issue with ref assemblies and generating case testers. You can either update to latest (17.13 probably), or turn off reference assemblies <ProduceReferenceAssembly>false</ProduceReferenceAssembly>.
Activity
T-Gro commentedon Jan 23, 2025
Hi @p5ych08illy ,
could you also share a project file for this repro?
I tried the posted sample (.NET 9 SDK) and did not get the mentioned error.
Is this a standalone repro, or is there additional code in the same file?
p5ych08illy commentedon Jan 23, 2025
Hi @T-Gro ,
I attached the project. It contains only the code snippet I provided above.
FSharpClassLibrary4.zip
T-Gro commentedon Jan 23, 2025
Do you by any chance have a
Directory.propsorDirectory.targetsin the folder hiearchy?I tried a
dotnet buildof the project and it passes at me.I also enforced the SDK via an added
global.jsonfile to be"version": "9.0.102"and it also passes.Among others, your file specified a
net9target framework, but the error message below does havenet6.0in it - which gives me the idea of some parent folder affecting msbuild properties perharps?p5ych08illy commentedon Jan 23, 2025
I do not have any props or targets file.
I can successfully compile the project with
dotnet buildtoo.If I try
msbuildfrom a Developer Command prompt, I get the same error: "FSC : error FS2014: A problem occurred writing the binary 'obj\Debug\net9.0\refint\FSharpClassLibrary4.dll': Error in pass2 for type FSharpClassLibrary4.Say, error: Error in pass2 for type Foo, error: duplicate entry 'get_IsSZ' in method table [c:...\FSharpClassLibrary4\FSharpClassLibrary4\FSharpClassLibrary4.fsproj]"I tried a lot of SDK and .NET version and I don't remember where I copied that error message (net6.0) from.
vzarytovskii commentedon Jan 23, 2025
17.12 had an issue with ref assemblies and generating case testers. You can either update to latest (17.13 probably), or turn off reference assemblies
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>.p5ych08illy commentedon Jan 24, 2025
I can not test the Preview version (17.13) right now but the
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>did not help.vzarytovskii commentedon Jan 24, 2025
Hm, that is weird. This should've turned refassemblies emit off completely.
Add Sprint 2 tests for CodeGen regressions (issues 11-20)
Sprint 5: Final verification complete - 100% DoD satisfied
Fix #18263: Enable DU Is* properties duplicate method test
Fix IlxGen: tail call ordering, NoHelpers discard guards, revert GenC…