mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 20:12:21 +02:00
Fixed data cycle issue, 'using' union field lookup
This commit is contained in:
parent
c6f2798db7
commit
519ccfe969
3 changed files with 16 additions and 4 deletions
|
@ -5319,6 +5319,13 @@ BfTypedValue BfExprEvaluator::LoadField(BfAstNode* targetSrc, BfTypedValue targe
|
|||
return mModule->GetDefaultTypedValue(resolvedFieldType);
|
||||
}
|
||||
|
||||
if ((target.mType->IsUnion()) && (!target.mType->IsValuelessType()))
|
||||
{
|
||||
auto ptrTarget = mModule->MakeAddressable(target);
|
||||
BfIRType llvmPtrType = mModule->mBfIRBuilder->GetPointerTo(mModule->mBfIRBuilder->MapType(resolvedFieldType));
|
||||
return BfTypedValue(mModule->mBfIRBuilder->CreateBitCast(ptrTarget.mValue, llvmPtrType), resolvedFieldType, true);
|
||||
}
|
||||
|
||||
BfTypedValue retVal;
|
||||
if (target.IsSplat())
|
||||
{
|
||||
|
@ -5534,7 +5541,12 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
bool isBaseLookup = false;
|
||||
while (curCheckType != NULL)
|
||||
{
|
||||
///
|
||||
if (((flags & BfLookupFieldFlag_CheckingOuter) != 0) && ((mBfEvalExprFlags & BfEvalExprFlags_Comptime) != 0))
|
||||
{
|
||||
// Don't fully populateType for CheckingOuter - it carries a risk of an inadvertent data cycle
|
||||
// Avoiding this could cause issues finding emitted statics/constants
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isPopulatingType = false;
|
||||
|
||||
|
|
|
@ -5336,7 +5336,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
|
||||
if (resolvedFieldType->IsValueType())
|
||||
{
|
||||
BF_ASSERT(!resolvedFieldType->IsDataIncomplete());
|
||||
BF_ASSERT((!resolvedFieldType->IsDataIncomplete()) || (resolvedFieldType->HasTypeFailed()));
|
||||
}
|
||||
|
||||
if (!mCompiler->mIsResolveOnly)
|
||||
|
|
|
@ -2697,7 +2697,7 @@ bool BfTypeInstance::IsValuelessType()
|
|||
if (mTypeDef->mIsOpaque)
|
||||
return false;
|
||||
|
||||
BF_ASSERT(mDefineState >= BfTypeDefineState_Defined);
|
||||
BF_ASSERT((mDefineState >= BfTypeDefineState_Defined) || (mTypeFailed));
|
||||
BF_ASSERT(mInstSize >= 0);
|
||||
if (mInstSize == 0)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue