Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing the need for explicit numbering of enums in F#, possible fixing problem with struct decorated DU's without fields. #173

Open
kam1986 opened this issue Nov 1, 2023 · 0 comments

Comments

@kam1986
Copy link

kam1986 commented Nov 1, 2023

Description

In the process of optimizing some of my code, I noticed the problem where

[<Struct>]
type Tag =
     | Case0
          :
     | CaseN

Coursed the compiler to throw a compiler exception

System.InvalidProgramException: Common Language Runtime detected an invalid program

For any DU type where N >= 49 (50 cases)

I also noticed that the interpreter and compiler transform Enums (DUs' with assigned values) are converted into struct DUs', and they are not throwing the exception above.

Why is it, that fieldless DU's just are handled as enums? This seems like a rather simple workaround. the type inference system, should already have enough information to catch this and let the compiler make that choice. It would make enums where the value of a case are not important much simpler to implement, and solve the above problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant