dotnet / dotnet/fsharp

Misleading error message when lambda literals violate equality constraints

Open
#7,637 1 comment 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

**Repro steps**

```fsharp
type Foo<'T when 'T : equality> = Foo of 'T

// error FS0002: This function takes too many arguments, or is used in a context where a function is not expected
Foo (fun x -> x + 1)

// error FS0001: The type '(int -> int)' does not support the 'equality' constraint because it is a function type
let f x = x + 1 in Foo f
```

**Expected behavior**

The first expression should produce the same error message as the second expression.

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.