dotnet / dotnet/fsharp

confusing error message when method has overloads and is called with generic type argument

Open
#4,969 0 comments 0 reactions 0 assignees View on GitHub
Area-Diagnostics Feature Improvement
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

This code gives confusing error message:

```fsharp
type Foo() =
member x.A b = 1 + b
member x.A b = 1m + b

let foo = Foo()
foo.A 1
```

> error FS0503: A member or object constructor 'A' taking 1 arguments is not accessible from this code location. All accessible versions of method 'A' take 1 arguments.

It says no member accessible with 1 arguments (in plural), and says all versions of the member take 1 arguments (in plural)

If I take out second overload, I get:

> error FS0502: The member or object constructor 'A' takes 0 type argument(s) but is here given 1. The required signature is 'member Foo.A : b:int -> int'.

I'd expect that same message instead, but with the last part listing the overloads :

> error FS0502: The member or object constructor 'A' takes 0 type argument(s) but is here given 1. The
required signature are
> 'member Foo.A : b:int -> int'.
> 'member Foo.A : b:decimal -> decimal'.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.