1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Fix for unions where union val is non-addr and member is a reference

This commit is contained in:
Brian Fiete 2024-08-12 18:23:49 -04:00
parent 0964d7805e
commit f88e752303

View file

@ -5406,11 +5406,14 @@ BfTypedValue BfExprEvaluator::LoadField(BfAstNode* targetSrc, BfTypedValue targe
{
auto unionInnerType = typeInstance->GetUnionInnerType();
if (unionInnerType != resolvedFieldType)
{
if (!retVal.IsAddr())
retVal = mModule->MakeAddressable(retVal);
{
BfTypedValue unionTypedValue = retVal;
unionTypedValue.mType = unionInnerType;
if (!unionTypedValue.IsAddr())
unionTypedValue = mModule->MakeAddressable(unionTypedValue);
BfIRType llvmPtrType = mModule->mBfIRBuilder->GetPointerTo(mModule->mBfIRBuilder->MapType(resolvedFieldType));
retVal.mValue = mModule->mBfIRBuilder->CreateBitCast(retVal.mValue, llvmPtrType);
retVal.mValue = mModule->mBfIRBuilder->CreateBitCast(unionTypedValue.mValue, llvmPtrType);
retVal.mKind = unionTypedValue.mKind;
}
}