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

Fixed error/warning bool interference in AddErrorContext

This commit is contained in:
Brian Fiete 2021-12-30 11:27:17 -05:00
parent efbdc33622
commit be6e7edf02
3 changed files with 20 additions and 7 deletions

View file

@ -2847,7 +2847,7 @@ bool BfModule::IsSkippingExtraResolveChecks()
return mCompiler->IsSkippingExtraResolveChecks();
}
bool BfModule::AddErrorContext(StringImpl& errorString, BfAstNode* refNode, bool& isWhileSpecializing)
bool BfModule::AddErrorContext(StringImpl& errorString, BfAstNode* refNode, bool& isWhileSpecializing, bool isWarning)
{
bool isWhileSpecializingMethod = false;
if ((mIsSpecialModule) && (mModuleName == "vdata"))
@ -2867,6 +2867,9 @@ bool BfModule::AddErrorContext(StringImpl& errorString, BfAstNode* refNode, bool
auto _CheckMethodInstance = [&](BfMethodInstance* methodInstance)
{
// Propogate the fail all the way to the main method (assuming we're in a local method or lambda)
if (isWarning)
methodInstance->mHasWarning = true;
else
methodInstance->mHasFailed = true;
bool isSpecializedMethod = ((methodInstance != NULL) && (!methodInstance->mIsUnspecialized) && (methodInstance->mMethodInfoEx != NULL) && (methodInstance->mMethodInfoEx->mMethodGenericArguments.size() != 0));
@ -2880,11 +2883,19 @@ bool BfModule::AddErrorContext(StringImpl& errorString, BfAstNode* refNode, bool
BF_ASSERT(methodInstance->mMethodDef->mIsLocalMethod);
}
else
{
if (isWarning)
{
if (unspecializedMethod->mHasWarning)
return false; // At least SOME error has already been reported
}
else
{
if (unspecializedMethod->mHasFailed)
return false; // At least SOME error has already been reported
}
}
}
if (isSpecializedMethod)
{
@ -3000,7 +3011,7 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
String errorString = error;
bool isWhileSpecializing = false;
if (!AddErrorContext(errorString, refNode, isWhileSpecializing))
if (!AddErrorContext(errorString, refNode, isWhileSpecializing, false))
return NULL;
BfError* bfError = NULL;
@ -3145,7 +3156,7 @@ BfError* BfModule::Warn(int warningNum, const StringImpl& warning, BfAstNode* re
String warningString = warning;
bool isWhileSpecializing = false;
if (!AddErrorContext(warningString, refNode, isWhileSpecializing))
if (!AddErrorContext(warningString, refNode, isWhileSpecializing, true))
return NULL;
bool deferWarning = isWhileSpecializing;

View file

@ -1528,7 +1528,7 @@ public:
void SetFail();
void VerifyOnDemandMethods();
bool IsSkippingExtraResolveChecks();
bool AddErrorContext(StringImpl& errorString, BfAstNode* refNode, bool& isWhileSpecializing);
bool AddErrorContext(StringImpl& errorString, BfAstNode* refNode, bool& isWhileSpecializing, bool isWarning);
BfError* Fail(const StringImpl& error, BfAstNode* refNode = NULL, bool isPersistent = false, bool deferError = false);
BfError* FailInternal(const StringImpl& error, BfAstNode* refNode = NULL);
BfError* FailAfter(const StringImpl& error, BfAstNode* refNode);

View file

@ -839,6 +839,7 @@ public:
bool mHasBeenDeclared:1;
bool mHasBeenProcessed:1;
bool mHasFailed:1;
bool mHasWarning:1;
bool mFailedConstraints:1;
bool mMangleWithIdx:1;
bool mHadGenericDelegateParams:1;
@ -880,6 +881,7 @@ public:
mHasBeenDeclared = false;
mHasBeenProcessed = false;
mHasFailed = false;
mHasWarning = false;
mFailedConstraints = false;
mMangleWithIdx = false;
mHadGenericDelegateParams = false;