Skip to content

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

Closed

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

Activity

  1. added this to the Backlog milestone on Aug 4, 2026
  2. changed the title [-]Release-only InvalidProgramException: yield! over Seq.collect of ImmutableArray in a list comprehension[/-] [+]Release-only InvalidProgramException: Seq.collect over a struct collection (ImmutableArray) materialised with List.ofSeq[/+] on Aug 4, 2026
  3. self-assigned this
    on Aug 6, 2026
  4. added
    Area-Compiler-CodeGen
    and removed on Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area-Compiler-CodeGen

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions