From be6e7edf020212664496ea2b14b7dab173f3da43 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 30 Dec 2021 11:27:17 -0500 Subject: [PATCH] Fixed error/warning bool interference in AddErrorContext --- IDEHelper/Compiler/BfModule.cpp | 23 +++++++++++++++++------ IDEHelper/Compiler/BfModule.h | 2 +- IDEHelper/Compiler/BfResolvedTypeUtils.h | 2 ++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 65cc337c..5645ef32 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -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,7 +2867,10 @@ 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) - methodInstance->mHasFailed = true; + if (isWarning) + methodInstance->mHasWarning = true; + else + methodInstance->mHasFailed = true; bool isSpecializedMethod = ((methodInstance != NULL) && (!methodInstance->mIsUnspecialized) && (methodInstance->mMethodInfoEx != NULL) && (methodInstance->mMethodInfoEx->mMethodGenericArguments.size() != 0)); if (isSpecializedMethod) @@ -2881,8 +2884,16 @@ bool BfModule::AddErrorContext(StringImpl& errorString, BfAstNode* refNode, bool } else { - if (unspecializedMethod->mHasFailed) - return false; // At least SOME error has already been reported + 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 + } } } @@ -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; diff --git a/IDEHelper/Compiler/BfModule.h b/IDEHelper/Compiler/BfModule.h index 5f721261..153344ab 100644 --- a/IDEHelper/Compiler/BfModule.h +++ b/IDEHelper/Compiler/BfModule.h @@ -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); diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.h b/IDEHelper/Compiler/BfResolvedTypeUtils.h index ee281ccf..925ff5f8 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.h +++ b/IDEHelper/Compiler/BfResolvedTypeUtils.h @@ -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;