Seq.collect whose 'Collection type parameter is instantiated to a struct collection (e.g. ImmutableArray<T>), materialised with List.ofSeq/Seq.toList, produces invalid IL under release optimization.
Repro
module Repro
open System
open System.Collections.Immutable
let f() = [ ImmutableArray.Create(1, 2) ] |> Seq.collect id |> List.ofSeq
[<EntryPoint>]
let main _ =
Console.WriteLine((f()).Length)
0
dotnet run -c Debug prints 2. dotnet run -c Release:
Unhandled exception. System.InvalidProgramException: Common Language Runtime detected an invalid program.
at Repro.f()
Environment
- .NET SDK 10.0.302
- FSharp.Core 10.1.300
net10.0, Windows 11 x64
Seq.collectwhose'Collectiontype parameter is instantiated to a struct collection (e.g.ImmutableArray<T>), materialised withList.ofSeq/Seq.toList, produces invalid IL under release optimization.Repro
dotnet run -c Debugprints2.dotnet run -c Release:Environment
net10.0, Windows 11 x64