1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Fixed for discriminated unions with attempted initializers

This commit is contained in:
Brian Fiete 2020-09-22 08:34:16 -07:00
parent fd3265445d
commit 2192305800

View file

@ -3659,8 +3659,8 @@ void BfModule::ResolveConstField(BfTypeInstance* typeInstance, BfFieldInstance*
Fail("Const requires initializer", fieldDef->mFieldDeclaration->mNameNode);
}
}
else
{
else if (mBfIRBuilder != NULL)
{
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, typeInstance);
SetAndRestoreValue<bool> prevIgnoreWrite(mBfIRBuilder->mIgnoreWrites, true);
@ -3692,6 +3692,12 @@ void BfModule::ResolveConstField(BfTypeInstance* typeInstance, BfFieldInstance*
constValue = uncastedInitValue.mValue;
}
if ((mCurTypeInstance->IsPayloadEnum()) && (fieldDef->IsEnumCaseEntry()))
{
// Illegal
constValue = BfIRValue();
}
mBfIRBuilder->SetInsertPoint(prevInsertBlock);
}