Skip to content

Type inference regression in type-associated operators #4063

@nickcowle

Description

@nickcowle
type 'a Foo = Foo of 'a
with
    static member (|~>) (Foo a, f) = Foo (f a)

// Works fine in both F# 4.0 and 4.1
let x = Foo (1, 2) |~> fst

type Tuple =
    static member first (a, _) = a
    static member first (a, _, _) = a

// Works in F# 4.0, but gives a compile error in 4.1
let y = Foo (1, 2) |~> Tuple.first

The above code snippet works just fine with F# 4.0 (run it through fsi and you'll see it exits without error), but try to run or compile it with F# 4.1 and you'll get the following error:

example.fsx(13,24): error FS0505: The member or object constructor 'first' does not take 1 argument(s). An overload was found taking 2 arguments.

I suspect this is another type inference regression, similar to the one spotted in #2730. Unfortunately, the fix that went out for #2730 does not appear to have fixed this one. As with the other regression, this is sadly causing issues in our production codebase and making our migration to Visual Studio 2017 and F# 4.1 rather difficult.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions