Beef icon indicating copy to clipboard operation
Beef copied to clipboard

[Bug][Crash] Failure during codegen for boxed struct that was returned as generic interface

Open kallisto56 opened this issue 10 months ago • 0 comments

Hi there,

Reproducible on latest nightly (https://github.com/beefytech/Beef/commit/1805316b70387a8cfabdee45f1e5204fa0c5d649) and previous builds. Ready-for-testing project: bug.2165.zip While working on the issue https://github.com/beefytech/Beef/issues/926, I've encountered a situation in which compiler fails during codegen:

Failure during codegen of ?get__mState@?$Box@UDoor@bug2165@bf@@@@QEAA?AW4StateType@bug2165@bf@@XZ
in BOX_bug2165_Door:
Assert 'retCount == 1' failed on line 18284
 MCBlock: entry:0

Excerpt:

class Program
{
	static void Main ()
	{
		IState<StateType> doorState = Build();
		Debug.WriteLine("{}", doorState.mState); // << Failure during codegen
		delete doorState;
	}

	static IState<StateType> Build ()
	{
		return new box Door(.Opened);
	}
}


interface IState<T1>
where T1 :enum
{
	T1 mState { get; set mut; }
}

struct Door : IState<StateType>
{
	public StateType mState { get; set mut; }

	public this (StateType state)
	{
		mState = state;
	}
}

enum StateType
{
	Opened,
	Closed,
}

enum TriggerType
{
	DoorHandle,
}

kallisto56 avatar Feb 24 '25 10:02 kallisto56