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:
parent
0964d7805e
commit
f88e752303
1 changed files with 7 additions and 4 deletions
|
@ -5406,11 +5406,14 @@ BfTypedValue BfExprEvaluator::LoadField(BfAstNode* targetSrc, BfTypedValue targe
|
||||||
{
|
{
|
||||||
auto unionInnerType = typeInstance->GetUnionInnerType();
|
auto unionInnerType = typeInstance->GetUnionInnerType();
|
||||||
if (unionInnerType != resolvedFieldType)
|
if (unionInnerType != resolvedFieldType)
|
||||||
{
|
{
|
||||||
if (!retVal.IsAddr())
|
BfTypedValue unionTypedValue = retVal;
|
||||||
retVal = mModule->MakeAddressable(retVal);
|
unionTypedValue.mType = unionInnerType;
|
||||||
|
if (!unionTypedValue.IsAddr())
|
||||||
|
unionTypedValue = mModule->MakeAddressable(unionTypedValue);
|
||||||
BfIRType llvmPtrType = mModule->mBfIRBuilder->GetPointerTo(mModule->mBfIRBuilder->MapType(resolvedFieldType));
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue