Reword or better explain unique names on Struct DUs
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
## What
When creating a multi-case struct DU, if there is more than one field across all cases, each fields across all cases must have explicits, unique name e.g.
```fsharp
[]
type Foo =
| Hi of bool
| Lo of int
```
leads to
```
error FS3204: If a union type has more than one case and is a struct, then all fields within the union type must be given unique names
```
## Why
The error is misleading IMHO. Firstly, it's not clear to me under what circumstances this error appears e.g. this compiles fine:
```fsharp
[]
type Foo =
| Hi of bool
| Lo of int * bool
```
Nonetheless, the main issue is that the error message makes me think that all *named* fields must be unique i.e. surely the compiler can generate unique names for the other ones?
Yet this works:
```fsharp
[]
type Foo =
| Hi of bool
| Lo of bar:int
```
But this doesn't
```fsharp
[]
type Foo =
| Hi of bool
| Lo of bar:int
| Med of int
```
In short, the compiler error message doesn't clearly explain when this error occurs, or how to resolve it.
## How
The error message should clearly state how this error occurred (I would suggest something but I'm not entirely clear myself at the moment), and it should ideally give a hint as to how to fix the issue with the offending fields that have duplicated names.
Contributor guide
Assessment
This issue has not been assessed yet.