mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-05 07:45:59 +02:00
Improved mixin errors while specializing methods/types
This commit is contained in:
parent
f1b7f8151a
commit
5677f27cac
1 changed files with 33 additions and 32 deletions
|
@ -2913,6 +2913,7 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
||||||
errorString += StrFormat("\n while specializing type '%s'", TypeToString(mCurTypeInstance).c_str());
|
errorString += StrFormat("\n while specializing type '%s'", TypeToString(mCurTypeInstance).c_str());
|
||||||
isWhileSpecializing = true;
|
isWhileSpecializing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2943,17 +2944,10 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep in mind that all method specializations with generic type instances as its method generic params
|
BfError* bfError = NULL;
|
||||||
// need to be deferred because the specified generic type instance might get deleted at the end of the
|
|
||||||
// compilation due to no longer having indirect references removed, and we have to ignore errors from
|
if (isWhileSpecializing)
|
||||||
// those method specializations if that occurs
|
deferError = true;
|
||||||
if ((isWhileSpecializing) || (deferError))
|
|
||||||
{
|
|
||||||
BfError* bfError = mCompiler->mPassInstance->DeferFail(errorString, refNode);
|
|
||||||
if (bfError != NULL)
|
|
||||||
bfError->mIsWhileSpecializing = isWhileSpecializing;
|
|
||||||
return bfError;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!isWhileSpecializing) && (mCurTypeInstance != NULL) && ((mCurTypeInstance->IsGenericTypeInstance()) && (!mCurTypeInstance->IsUnspecializedType())))
|
if ((!isWhileSpecializing) && (mCurTypeInstance != NULL) && ((mCurTypeInstance->IsGenericTypeInstance()) && (!mCurTypeInstance->IsUnspecializedType())))
|
||||||
{
|
{
|
||||||
|
@ -2966,7 +2960,7 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
||||||
|
|
||||||
if ((mCurMethodState != NULL) && (mCurMethodState->mEmitRefNode != NULL))
|
if ((mCurMethodState != NULL) && (mCurMethodState->mEmitRefNode != NULL))
|
||||||
{
|
{
|
||||||
BfError* bfError = mCompiler->mPassInstance->Fail("Emitted code had errors", mCurMethodState->mEmitRefNode);
|
bfError = mCompiler->mPassInstance->Fail("Emitted code had errors", mCurMethodState->mEmitRefNode);
|
||||||
if (bfError != NULL)
|
if (bfError != NULL)
|
||||||
mCompiler->mPassInstance->MoreInfo(errorString, refNode);
|
mCompiler->mPassInstance->MoreInfo(errorString, refNode);
|
||||||
return bfError;
|
return bfError;
|
||||||
|
@ -2974,17 +2968,25 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
||||||
|
|
||||||
// Check mixins
|
// Check mixins
|
||||||
{
|
{
|
||||||
auto checkMethodInstance = mCurMethodState;
|
auto checkMethodState = mCurMethodState;
|
||||||
while (checkMethodInstance != NULL)
|
while (checkMethodState != NULL)
|
||||||
{
|
{
|
||||||
auto rootMixinState = checkMethodInstance->GetRootMixinState();
|
auto rootMixinState = checkMethodState->GetRootMixinState();
|
||||||
if (rootMixinState != NULL)
|
if (rootMixinState != NULL)
|
||||||
{
|
{
|
||||||
BfError* bfError = mCompiler->mPassInstance->Fail(StrFormat("Failed to inject mixin '%s'", MethodToString(rootMixinState->mMixinMethodInstance).c_str()), rootMixinState->mSource);
|
String mixinErr = StrFormat("Failed to inject mixin '%s'", MethodToString(rootMixinState->mMixinMethodInstance).c_str());
|
||||||
if (bfError != NULL)
|
if (deferError)
|
||||||
|
bfError = mCompiler->mPassInstance->DeferFail(mixinErr, rootMixinState->mSource);
|
||||||
|
else
|
||||||
|
bfError = mCompiler->mPassInstance->Fail(mixinErr, rootMixinState->mSource);
|
||||||
|
|
||||||
|
if (bfError == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
bfError->mIsWhileSpecializing = isWhileSpecializing;
|
||||||
mCompiler->mPassInstance->MoreInfo(errorString, refNode);
|
mCompiler->mPassInstance->MoreInfo(errorString, refNode);
|
||||||
|
|
||||||
auto mixinState = checkMethodInstance->mMixinState;
|
auto mixinState = checkMethodState->mMixinState;
|
||||||
while ((mixinState != NULL) && (mixinState->mPrevMixinState != NULL))
|
while ((mixinState != NULL) && (mixinState->mPrevMixinState != NULL))
|
||||||
{
|
{
|
||||||
mCompiler->mPassInstance->MoreInfo(StrFormat("Injected from mixin '%s'", MethodToString(mixinState->mPrevMixinState->mMixinMethodInstance).c_str()), mixinState->mSource);
|
mCompiler->mPassInstance->MoreInfo(StrFormat("Injected from mixin '%s'", MethodToString(mixinState->mPrevMixinState->mMixinMethodInstance).c_str()), mixinState->mSource);
|
||||||
|
@ -2994,22 +2996,21 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
||||||
return bfError;
|
return bfError;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMethodInstance = checkMethodInstance->mPrevMethodState;
|
checkMethodState = checkMethodState->mPrevMethodState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BfError* bfError = NULL;
|
if (deferError)
|
||||||
if (refNode == NULL)
|
bfError = mCompiler->mPassInstance->Fail(errorString, refNode);
|
||||||
|
else if (refNode == NULL)
|
||||||
bfError = mCompiler->mPassInstance->Fail(errorString);
|
bfError = mCompiler->mPassInstance->Fail(errorString);
|
||||||
else
|
else
|
||||||
{
|
|
||||||
bfError = mCompiler->mPassInstance->Fail(errorString, refNode);
|
bfError = mCompiler->mPassInstance->Fail(errorString, refNode);
|
||||||
}
|
|
||||||
if (bfError != NULL)
|
if (bfError != NULL)
|
||||||
{
|
{
|
||||||
|
bfError->mIsWhileSpecializing = isWhileSpecializing;
|
||||||
bfError->mProject = mProject;
|
bfError->mProject = mProject;
|
||||||
bfError->mIsPersistent = isPersistent;
|
bfError->mIsPersistent = isPersistent;
|
||||||
bfError->mIsWhileSpecializing = isWhileSpecializing;
|
|
||||||
|
|
||||||
if ((mCurMethodState != NULL) && (mCurMethodState->mDeferredCallEmitState != NULL) && (mCurMethodState->mDeferredCallEmitState->mCloseNode != NULL))
|
if ((mCurMethodState != NULL) && (mCurMethodState->mDeferredCallEmitState != NULL) && (mCurMethodState->mDeferredCallEmitState->mCloseNode != NULL))
|
||||||
mCompiler->mPassInstance->MoreInfo("Error during deferred statement handling", mCurMethodState->mDeferredCallEmitState->mCloseNode);
|
mCompiler->mPassInstance->MoreInfo("Error during deferred statement handling", mCurMethodState->mDeferredCallEmitState->mCloseNode);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue