Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

F# 9.0 Invalid sample for struct discriminated unions #4042

Open
ryanovic opened this issue Jan 6, 2025 · 1 comment
Open

F# 9.0 Invalid sample for struct discriminated unions #4042

ryanovic opened this issue Jan 6, 2025 · 1 comment
Labels
bug Something isn't working Pri3

Comments

@ryanovic
Copy link

ryanovic commented Jan 6, 2025

In the language reference document(Discriminated Unions) provided the following F# code example:

[<Struct>]
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) 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.

image

@ryanovic ryanovic added the bug Something isn't working label Jan 6, 2025
Copy link

welcome bot commented Jan 6, 2025

Thank you for opening an issue! One of our team members will get back to you with additional information.

If this is a product issue, please close this issue and contact the product's support instead. For a list of support websites, see Support for Microsoft products and apps.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working Pri3
Projects
None yet
Development

No branches or pull requests

1 participant