Advertisement

Failed assertion when setting reference of class in foreach

Started by January 16, 2025 07:38 PM
1 comment, last by WitchLord 1 week, 6 days ago
class R
{
	R(){}
}
class C
{
	R@ Reference;
	C()
	{
	@Reference = null;
	}
}
array<C> Array;
void Main()
{
	for (uint i = 0; i < 10; i++)
	{
		Array.insertLast(C());
	}
	foreach (C ExampleClass : Array)
	{
		@ExampleClass.Reference = R();
	}
}

Here is the minimal reproduction case, note that replacing the foreach loop at the bottom with a reqular for loop does not make the assertion error show up:

	for (uint i = 0; i < Array.Length; i++) // for loop
	{
		auto ExampleClass = Array[i];
		@ExampleClass.Reference = R();
	}

None

Thanks for the bug report and the snippet for reproducing the error.

I'll investigate and fix it as soon as possible.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement