Skip to content

Another repro of LocallyAbortOperationThatFailsToResolveOverload #8520

@NinoFloris

Description

@NinoFloris

This seems to be the smallest sample to get LocallyAbortOperationThatFailsToResolveOverload.

type Foo = 
    static member Bar (x: int) = ()
    static member Bar (x: bool) = ()

    static member inline Invoke source = 
        let inline call (_: ^M, _: ^N, a: ^a) =
            ((^M or ^N): (static member Bar: _ -> _)(a))

        call (Unchecked.defaultof<Foo>, Unchecked.defaultof<_>, source)

        // or similarly but gives a different error location at null
        call (Unchecked.defaultof<Foo>, null, source)

        // no inference here so this returns a nice overload ambiguity error
        call (Unchecked.defaultof<Foo>, Unchecked.defaultof<obj>, source)
    error FS0071: Type constraint mismatch when applying the default type 'obj' for a type inference variable. internal error: Exception of type 'FSharp.Compiler.ConstraintSolver+LocallyAbortOperationThatFailsToResolveOverload' was thrown. Consider adding further type constraints

It was fairly educational to see handling of this differ between Unchecked.defaultof<_> null and Unchecked.defaultof<obj>.

I assume this is fixed in #8294

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions