Skip to content

FS0073 internal error: Undefined or unsolved type variable: 'C, intermittent in Release #20812

Description

@xperiandri

The compiler fails now and then with error FS0073: internal error: Undefined or unsolved type variable: 'C while it compiles a test project in Release. The next build of the same sources succeeds. 6 of 66 builds failed in my measurements, and none of 72 builds failed with --parallelcompilation-.

The error is reported at a lambda in a member of a generic abstract class. The lambda captures a constructor parameter, a record of functions over the type parameter of the class, and is passed to a method of the base class:

[<AbstractClass>]
type SeqLikeAccessContract<'C> (ops : SeqOps<'C>) =
    inherit SeqContractBase<'C> (ops)

    [<TestMethod>]
    member this.``head throws for an empty collection as FSharp.Core does`` () =
        this.ThrowsLikeFSharpCore (
            (fun () -> Array.head Array.empty<int>),
            (fun () -> List.head List.empty<int>),
            (fun () -> ops.Head (ops.OfSeq Inputs.Empty)), // SeqLikeAccessContract.fs(81,14)
            "head of an empty collection must throw"
        )

Repro steps

FSharp.Collections.Immutable-fs0073-repro.zip

  1. Install the .NET SDK 10.0.402 and PowerShell 7. The failure was seen on Windows, Ubuntu and macOS.
  2. Unpack the attached FSharp.Collections.Immutable-fs0073-repro.zip. It holds the tree of fsprojects/FSharp.Collections.Immutable@58af8f1, reduced to what the build needs, and repro.ps1.
  3. Run pwsh ./repro.ps1 in the unpacked folder. It builds the library once and compiles the test project in Release again and again (dotnet build -c Release -f net10.0 --no-dependencies --no-incremental) until FS0073 appears, 60 builds at most. About 9 builds in 100 fail; the first failure came after 23 and after 10 builds in two runs.

Expected behavior

Every build succeeds.

Actual behavior

10/80: FAILED (21,3 s) ...\tests\FSharp.Collections.Immutable.Tests\Contracts\SeqLike\SeqLikeAccessContract.fs(81,14): error FS0073: internal error: Undefined or unsolved type variable: 'C [...\FSharp.Collections.Immutable.Tests.fsproj::TargetFramework=net10.0]

The compiler gives no stack trace. The same error showed up on the GitHub Actions runners windows-latest, ubuntu-latest and macos-latest, for both target frameworks (net8.0 and net10.0), in the same file.

Known workarounds

Compile without parallel compilation: <ParallelCompilation>false</ParallelCompilation> in the project, or pwsh ./repro.ps1 -ExtraArguments '-p:ParallelCompilation=false'. None of 72 builds failed. The compiler warns with FS0075 ("The command-line option '--parallelcompilation' is for test purposes only").

Related information

  • Windows 11 with 32 logical processors. The failure also appears when the process is restricted to 4 logical processors (3 of 24 builds), and on the Linux and macOS runners of GitHub Actions.
  • .NET SDK 10.0.402 (FSharp.Compiler.Service 43.12.402), FSharp.Core 10.1.301.
  • Release configuration, net8.0 and net10.0, LangVersion 10.0, nullable reference types on.
  • Without the switch 6 of 66 builds failed (2 of 12, 1 of 30 and 3 of 24 on 4 processors). With --parallelcompilation- none of 72 failed.

Activity

  1. added theissue type on Oct 19, 2026
  2. added this to the Backlog milestone on Oct 19, 2026
  3. majocha commented on Oct 20, 2026

    @majocha
    Contributor

    Apparently, this still happens on main but now is masked by c038195 and just produces wrong IL.
    Specifically GenTypeAux fallback added in #19710 is now masking it. Given the great many callsites in IlxGen I'd review again to make sure that fallback is safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions