F# 9.0 Invalid sample for struct discriminated unions
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 19h 10m
- Merged PRs (30d)
- 268
Description
---
**Issue moved from microsoftdocs/feedback#4042**
- Please respond to @ryanovic.
---
_From @ryanovic on Monday, January 6, 2025 2:17:34 PM_
In the language reference document([Discriminated Unions](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/discriminated-unions#struct-discriminated-unions)) provided the following F# code example:
```
[]
type Multicase =
| Case1 of string
| Case2 of int
| Case3 of double
```
Which is not correct, and would not compile with the recent .net9 SDK(error FS3585: If a multicase union type is a struct, then all fields with the same name must be of the same type). According to the other article([What's new in F# 9](https://learn.microsoft.com/en-us/dotnet/fsharp/whats-new/fsharp-9#field-sharing-for-struct-discriminated-unions)) only fields which have the same name **and type,** can share the same memory location, so it will not work for string / int / double intersection.

---
#### Document Details
⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*
* ID: 6020749e-d91e-8a1b-5366-25b212baa31d
* Version Independent ID: 0f28f508-dc0f-c272-383e-ec768759fe16
* Content: [Discriminated Unions - F#](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/discriminated-unions#struct-discriminated-unions)
* Content Source: [docs/fsharp/language-reference/discriminated-unions.md](https://github.com/dotnet/docs/blob/main/docs/fsharp/language-reference/discriminated-unions.md)
* Service: **dotnet-fsharp**
* GitHub Login: @KathleenDollard
* Microsoft Alias: **kdollard**
Contributor guide
Assessment
This issue has not been assessed yet.