Repository navigation
FS2014 duplicate entry '.cctor' in method table #18767
Copy link
Copy link
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone
Description
Please provide a succinct description of the issue.
Union case without of xxxx causes
1>FSC : error FS2014: A problem occurred writing the binary 'G:\coldfar_py\sharftrade9\Libs5\KServer\fstring\obj\Release\netstandard2.0\PersistedConcurrentSortedList.dll': Error in pass2 for type PersistedConcurrentSortedList.Type.fCell2`1, error: duplicate entry '.cctor' in method table
1>Done building project "PersistedConcurrentSortedList.fsproj" -- FAILED.
1>FSC : error FS2014: A problem occurred writing the binary 'G:\coldfar_py\sharftrade9\Libs5\KServer\fstring\obj\Release\net9.0\PersistedConcurrentSortedList.dll': Error in pass2 for type PersistedConcurrentSortedList.Type.fCell2`1, error: duplicate entry '.cctor' in method table
1>Done building project "PersistedConcurrentSortedList.fsproj" -- FAILED.
[<ProtoBuf.ProtoContract>]
type fCell2<'CellTupleKey when 'CellTupleKey: comparison> =
| B of bool
| S of string
| D of decimal
| A of fCell2<'CellTupleKey> []
| T of 'CellTupleKey * fCell2<'CellTupleKey>
| N
member this.toJsonString() =
let rec toJson (f: fCell2<'CellTupleKey>) =
match f with
| S s -> sprintf "%s" s
| D d -> sprintf "%f" d
| A arr ->
let elements = arr |> Array.map toJson |> String.concat ", "
sprintf "[%s]" elements
| T (key, value) ->
let keyStr = sprintf "%A" key
let valueStr = toJson value
sprintf "%A: %s" keyStr valueStr
toJson this
static member compareArrays (arr1: fCell2<'CellTupleKey> array) (arr2: fCell2<'CellTupleKey> array): int =
Seq.zip arr1 arr2
|> Seq.tryPick (fun (x, y) ->
let res = compare x y
if res = 0 then None else Some res)
|> Option.defaultValue 0
static member compareLength (arr1: fCell2<'CellTupleKey> array) (arr2: fCell2<'CellTupleKey> array): int =
let a1l = if arr1 = null then 0 else arr1.Length
let a2l = if arr2 = null then 0 else arr2.Length
compare a1l a2l
static member Compare (x: fCell2<'CellTupleKey>, y: fCell2<'CellTupleKey>): int =
match box x, box y with
| null, null -> 0
| _, null ->
if x = S null then 0 else 1
| null, _ ->
if y = S null then 0 else -1
| _ ->
match (x, y) with
| (D d1, D d2) -> Decimal.Compare(d1, d2)
| (S s1, S s2) -> String.Compare(s1, s2, StringComparison.OrdinalIgnoreCase)
| (A arr1, A arr2) ->
let lenComp = fCell2.compareLength arr1 arr2
if lenComp <> 0 then lenComp
else fCell2.compareArrays arr1 arr2
| (T (tag1, f1), T (tag2, f2)) ->
let tagComp = compare tag1 tag2
if tagComp <> 0 then tagComp
else fCell2.Compare(f1, f2)
| (D _, _) -> -1
| (_, D _) -> 1
| (S _, (A _ | T _)) -> -1
| ((A _ | T _), S _) -> 1
| (A _, T _) -> -1
| (T _, A _) -> 1
interface IComparer<fCell2<'CellTupleKey>> with
override this.Compare(x: fCell2<'CellTupleKey>, y: fCell2<'CellTupleKey>): int =
fCell2.Compare(x, y)
If possible attach a zip file with the repro case. This often makes it easier for others to reproduce.
The zip file should ideally represent the situation just before the call/step that is problematic.
https://github.com/ingted/PersistedConcurrentSortedList
(After add | N to PB2.fsx)
The expected behavior.
Should be able to compile successfully.
Provide a description of the actual behaviour observed.
| N of unit
Provide a description of any known workarounds.
- Operating system Win Server 2019
- .NET Runtime kind (.NET Core, .NET Framework, Mono): .NET 9.0.303
- Editing Tools (e.g. Visual Studio Version, Visual Studio): VS 2022
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Type
Projects
- StatusShow more project fieldsNew
Activity
ingted commentedon Jul 21, 2025
Seems caused by "static member val xxxx" definition...
T-Gro commentedon Jul 21, 2025
Can you please point me to a
static member valin there please?brianrourkeboll commentedon Jul 21, 2025
Minimal repro:
Not OK
Generic DU, nullary case,
static member val.OK
OK
OK
ingted commentedon Jul 21, 2025
Sorry it was just a code snippet... (complete one is in the repo)
Thanks @brianrourkeboll for the great reproduce !!!
Implement de-duplication logic for .cctor methods in IlxGen.fs