Skip to content

Improve error reporting: Member implementation with tuple argument(s) #1203

@JanWosnitza

Description

@JanWosnitza

Related to #1200

What

There is a difference between int32 * int32 -> unit and (int32 * int32) -> unit. The first one generates 2 parameters and the second one generates 1 tuple parameter. One might stumble upon this error:

type IInterface =
    abstract Function : (int32 * int32) -> unit

{ new IInterface with
    member this.Function (i, j) = ()
}

FS0768: The member 'Function' does not accept the correct number of arguments, 1 arguments are expected

Why

The error message is confusing, because one might not expect the brackets to change the overall function signature and assume to the result as with:

type IInterface =
    abstract Function : int32 * int32 -> unit

{ new IInterface with
    member this.Function (i, j) = ()
}

How

Trying to address @forki proposals ( #1200 (comment) ):

  • it should be singular
  • it could hint the signature of Function
  • it could tell something about tuples vs. "C# style parameters"

E.g.:

FS0768: The member 'Function : (int32 * int32) -> unit' does not accept the correct number of arguments. Expecting 1 argument
    (int32 * int32)
but given are 2 arguments
    int32 * int32
Member functions with a single tuple argument are compiled to C#-ish parameters instead of a single parameter of type tuple, unless forced otherwise.

I am unsure about the "tuples vs C# style parameters" explanation (also a native speaker should choose the exact wording :) )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions