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

Fixed detection of data cycles within unions

This commit is contained in:
Brian Fiete 2020-05-13 07:42:57 -07:00
parent 706153348a
commit 577cd2e270
3 changed files with 27 additions and 3 deletions

View file

@ -704,6 +704,12 @@ bool BfModule::CheckCircularDataError()
if (checkTypeState == NULL)
return hadError;
if (checkTypeState->mResolveKind == BfTypeState::ResolveKind_UnionInnerType)
{
checkTypeState = checkTypeState->mPrevState;
continue;
}
if (isPreBaseCheck)
{
if (checkTypeState->mPopulateType != BfPopulateType_Declaration)
@ -729,7 +735,15 @@ bool BfModule::CheckCircularDataError()
{
if (checkTypeState == NULL)
return hadError;
if ((checkTypeState->mCurAttributeTypeRef == NULL) && (checkTypeState->mCurBaseTypeRef == NULL) && (checkTypeState->mCurFieldDef == NULL))
if (checkTypeState->mResolveKind == BfTypeState::ResolveKind_UnionInnerType)
{
// Skip over this to actual data references
checkTypeState = checkTypeState->mPrevState;
continue;
}
if ((checkTypeState->mCurAttributeTypeRef == NULL) && (checkTypeState->mCurBaseTypeRef == NULL) && (checkTypeState->mCurFieldDef == NULL) )
return hadError;
// We only get one chance to fire off these errors, they can't be ignored.
@ -2762,7 +2776,10 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
}
}
if (typeInstance->mIsUnion)
unionInnerType = typeInstance->GetUnionInnerType();
{
SetAndRestoreValue<BfTypeState::ResolveKind> prevResolveKind(typeState.mResolveKind, BfTypeState::ResolveKind_UnionInnerType);
unionInnerType = typeInstance->GetUnionInnerType();
}
if (!isOrdered)
{