Skip to content

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

@kam1986

Description

@kam1986

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions