Skip to content

Release-only InvalidProgramException: Seq.collect over a struct collection (ImmutableArray) materialised with List.ofSeq #20203

Description

@charlesroddie

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions