Skip to content

solve the grammar ambiguity with enum literals inside array literals and struct literals #2235

@schroffl

Description

@schroffl

Accepted Proposal


The new anonymous enum literals are great, but they don't to seem work with arrays. I assume that this is a bug.

Let's take this enum as an example:

const MyEnum = enum {Ok, Error};

Declaring a single variable works just fine:

var enum_instance: MyEnum = .Ok;

But an array of MyEnum does not:

var enum_instances: []MyEnum = {.Error};

Which leads to the following compiler output:

error: expected token '=', found '}'

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThis proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions