Skip to content

Allow NEW_ENUM_VAL to use a case ID instead of a name #470

@egranata

Description

@egranata

In most cases, the compiler will see Foo::Bar and need to tell Foo - hey make me an instance of "Bar", no I don't know it's ID, imagine:

enum A { case Bar, Case Baq }
enum B { case Foo, case Bar }

func foo(n: Int) {
    val Foo = (n == 2) ? A : B;
    return Foo::Bar;
}

foo(Int.parse(readln(""))); # or something like that

But for some well-known enums, e.g. Unit::unit, RuntimeError::OperationFailed("") and so on, the cases are ordered and well defined. Consider allowing passing an int const instead of a string const

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions