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

mHadValidateErrors propagation fix

This commit is contained in:
Brian Fiete 2025-03-23 07:49:01 -04:00
parent 0e79860ba9
commit 81a9478e77
3 changed files with 32 additions and 3 deletions

View file

@ -150,6 +150,8 @@ namespace IDETest
TestExt<int>.InnerB<int> c; TestExt<int>.InnerB<int> c;
TestExt<int>.InnerC d; TestExt<int>.InnerC d;
TestExt<float>.InnerC e; //FAIL TestExt<float>.InnerC e; //FAIL
List<String?> badArgType; //FAIL
} }
} }
} }

View file

@ -1846,6 +1846,7 @@ public:
bool AreConstraintsSubset(BfGenericParamInstance* checkInner, BfGenericParamInstance* checkOuter); bool AreConstraintsSubset(BfGenericParamInstance* checkInner, BfGenericParamInstance* checkOuter);
bool CheckConstraintState(BfAstNode* refNode); bool CheckConstraintState(BfAstNode* refNode);
void ValidateGenericParams(BfGenericParamKind genericParamKind, Span<BfGenericParamInstance*> genericParams); void ValidateGenericParams(BfGenericParamKind genericParamKind, Span<BfGenericParamInstance*> genericParams);
void SetGenericValidationError(BfTypeInstance* typeInst);
bool ShouldAllowMultipleDefinitions(BfTypeInstance* typeInst, BfTypeDef* firstDeclaringTypeDef, BfTypeDef* secondDeclaringTypeDef); bool ShouldAllowMultipleDefinitions(BfTypeInstance* typeInst, BfTypeDef* firstDeclaringTypeDef, BfTypeDef* secondDeclaringTypeDef);
void CheckInjectNewRevision(BfTypeInstance* typeInstance); void CheckInjectNewRevision(BfTypeInstance* typeInstance);
void InitType(BfType* resolvedTypeRef, BfPopulateType populateType); void InitType(BfType* resolvedTypeRef, BfPopulateType populateType);

View file

@ -394,6 +394,26 @@ void BfModule::ValidateGenericParams(BfGenericParamKind genericParamKind, Span<B
} }
} }
void BfModule::SetGenericValidationError(BfTypeInstance* typeInst)
{
if ((typeInst->mGenericTypeInfo == NULL) || (typeInst->mGenericTypeInfo->mHadValidateErrors))
return;
typeInst->mGenericTypeInfo->mHadValidateErrors = true;
for (auto depKV : typeInst->mDependencyMap)
{
auto depType = depKV.mKey;
auto depEntry = depKV.mValue;
if ((depEntry.mFlags & BfDependencyMap::DependencyFlag_TypeGenericArg) != 0)
{
BF_ASSERT(depType->IsGenericTypeInstance());
// If A<T> had validate errors then consider B<A<T>> to have validate errors
SetGenericValidationError(depType->ToTypeInstance());
}
}
}
bool BfModule::ValidateGenericConstraints(BfAstNode* typeRef, BfTypeInstance* genericTypeInst, bool ignoreErrors) bool BfModule::ValidateGenericConstraints(BfAstNode* typeRef, BfTypeInstance* genericTypeInst, bool ignoreErrors)
{ {
if ((mCurTypeInstance != NULL) && (mCurTypeInstance->IsTypeAlias()) && (mCurTypeInstance->IsGenericTypeInstance())) if ((mCurTypeInstance != NULL) && (mCurTypeInstance->IsTypeAlias()) && (mCurTypeInstance->IsGenericTypeInstance()))
@ -421,7 +441,7 @@ bool BfModule::ValidateGenericConstraints(BfAstNode* typeRef, BfTypeInstance* ge
mContext->mUnreifiedModule->PopulateType(underlyingType, BfPopulateType_Declaration); mContext->mUnreifiedModule->PopulateType(underlyingType, BfPopulateType_Declaration);
bool result = ValidateGenericConstraints(typeRef, underlyingGenericType, ignoreErrors); bool result = ValidateGenericConstraints(typeRef, underlyingGenericType, ignoreErrors);
if (underlyingGenericType->mGenericTypeInfo->mHadValidateErrors) if (underlyingGenericType->mGenericTypeInfo->mHadValidateErrors)
genericTypeInst->mGenericTypeInfo->mHadValidateErrors = true; SetGenericValidationError(genericTypeInst);
return result; return result;
} }
return true; return true;
@ -443,7 +463,7 @@ bool BfModule::ValidateGenericConstraints(BfAstNode* typeRef, BfTypeInstance* ge
auto outerType = GetOuterType(genericTypeInst); auto outerType = GetOuterType(genericTypeInst);
mContext->mUnreifiedModule->PopulateType(outerType, BfPopulateType_Declaration); mContext->mUnreifiedModule->PopulateType(outerType, BfPopulateType_Declaration);
if ((outerType->mGenericTypeInfo != NULL) && (outerType->mGenericTypeInfo->mHadValidateErrors)) if ((outerType->mGenericTypeInfo != NULL) && (outerType->mGenericTypeInfo->mHadValidateErrors))
genericTypeInst->mGenericTypeInfo->mHadValidateErrors = true; SetGenericValidationError(genericTypeInst);
} }
for (int paramIdx = startGenericParamIdx; paramIdx < (int)genericTypeInst->mGenericTypeInfo->mGenericParams.size(); paramIdx++) for (int paramIdx = startGenericParamIdx; paramIdx < (int)genericTypeInst->mGenericTypeInfo->mGenericParams.size(); paramIdx++)
@ -464,7 +484,7 @@ bool BfModule::ValidateGenericConstraints(BfAstNode* typeRef, BfTypeInstance* ge
if ((genericArg == NULL) || (!CheckGenericConstraints(BfGenericParamSource(genericTypeInst), genericArg, typeRef, genericParamInstance, NULL, &error))) if ((genericArg == NULL) || (!CheckGenericConstraints(BfGenericParamSource(genericTypeInst), genericArg, typeRef, genericParamInstance, NULL, &error)))
{ {
if (!genericTypeInst->IsUnspecializedTypeVariation()) if (!genericTypeInst->IsUnspecializedTypeVariation())
genericTypeInst->mGenericTypeInfo->mHadValidateErrors = true; SetGenericValidationError(genericTypeInst);
return false; return false;
} }
} }
@ -16051,6 +16071,12 @@ void BfModule::DoTypeToString(StringImpl& str, BfType* resolvedType, BfTypeNameF
{ {
BP_ZONE("BfModule::DoTypeToString"); BP_ZONE("BfModule::DoTypeToString");
if (resolvedType == NULL)
{
str += "NULL";
return;
}
if (resolvedType->mContext == NULL) if (resolvedType->mContext == NULL)
{ {
str += "*UNINITIALIZED TYPE*"; str += "*UNINITIALIZED TYPE*";