Skip to content

Another repro of LocallyAbortOperationThatFailsToResolveOverload #8520

Closed

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

Activity

  1. cartermp commented on Feb 12, 2020

    @cartermp
    Contributor

    @NinoFloris this now emits an overload error

    error FS0043: A unique overload for method 'Bar' could not be determined based on type information prior to this program point. A type annotation may be needed. Candidates: static member Foo.Bar : x:bool -> unit, static member Foo.Bar : x:int -> unit

    So I believe this can be closed unless you expect something different 🙂

  2. NinoFloris commented on Feb 12, 2020

    @NinoFloris
    ContributorAuthor

    Nice, closing.

  3. added this to the 16.6 milestone on Mar 16, 2020
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions