dotnet / dotnet/fsharp

Misleading error message when using [<CustomEquality>] or [<CustomComparison>] with a non-structural type

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

Description

If you mistakenly add the `[]` or `[CustomComparison>]` (or both) attributes to a non-structural type then you get a very misleading error message:

```
[]
type T() =
override __.Equals(_) = true
```

> error FS0377: This type uses an invalid mix of the attributes 'NoEquality', 'ReferenceEquality', 'StructuralEquality', 'NoComparison' and 'StructuralComparison' attributes

This causes confusion (see e.g. [this](http://stackoverflow.com/questions/34981686/how-make-net-mutable-dictionaryt-t-with-structuralcomparison-equality-in-f) StackOverflow question).

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.