Beef icon indicating copy to clipboard operation
Beef copied to clipboard

IOnTypeInit crash when adding discriminated union case to empty enum

Open avasopht opened this issue 6 months ago • 0 comments

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);
}

avasopht avatar Jun 17 '25 12:06 avasopht