Beef
Beef copied to clipboard
IOnTypeInit crash when adding discriminated union case to empty enum
Using Beef v0.43.5
Beef crashes when attempting to add a discriminated union case to an empty enum.
This is a minimum case to reproduce this:
// Attributes.bf
namespace BeefBugReport;
using System;
struct ComponentEnumAttribute : Attribute, IOnTypeInit
{
[Comptime]
public void OnTypeInit(Type type, Self* prev)
{
Compiler.EmitTypeBody(type, scope $"""
case ComponentKey(String key);
""");
}
}
// TestATtributes.bf
namespace BeefBugReport;
using System;
[ComponentEnum]
enum TestEnumAttribute { }
Further testing found that having an existing case clause with a parameter prevented the crash, e.g.
[ComponentEnum]
enum TestEnumAttribute
{
case Unknown(void);
}