Skip to content

IDE crash involving comptime enum case #2404

@Grimelios

Description

@Grimelios
[Case("MyCase(int)")]
public enum MyEnum
{
}

[AttributeUsage(.Enum)]
public struct CaseAttribute : Attribute, IOnTypeInit
{
    private String m_case;

    public this(String @case)
    {
        m_case = @case;
    }

    [Comptime]
    public void OnTypeInit(Type type, Self* prev)
    {
        Compiler.EmitTypeBody(type, scope $"case {m_case};");
    }
}

This code immediately crashes the IDE. Tested on 03/04/2026.

Two variants I've tested that compile successfully:

  1. Removing the enum's payload ([Case("MyCase")]).
  2. Adding a "dummy" case that includes a payload. An "empty" dummy case still crashes.
[Case("MyCase(int)")]
public enum MyEnum
{
    case Pad(int); // Compiles successfully.
    //case Pad; // Crashes!
}

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