From 18f7a5bd092f5211ce77aa8c8b1bf5849c8f277d Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Wed, 22 Jan 2025 08:04:38 -0800 Subject: [PATCH] Sanity check for mid-compile deleted types --- IDEHelper/Compiler/BfModule.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index a6c86296..4fd43582 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -20715,6 +20715,21 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup, return; } + auto _SanityCheckType = [&](BfType* type) + { + if ((type != NULL) && (type->IsDeleting())) + { + InternalError("Method references deleted type", methodDef->GetRefNode()); + return false; + } + return true; + }; + if (!_SanityCheckType(methodInstance->mReturnType)) + return; + for (int paramIdx = 0; paramIdx < methodInstance->GetParamCount(); paramIdx++) + if (!_SanityCheckType(methodInstance->GetParamType(paramIdx))) + return; + StringT<512> mangledName; BfMangler::Mangle(mangledName, mCompiler->GetMangleKind(), mCurMethodInstance); if (!methodInstance->mIRFunction) @@ -26101,6 +26116,15 @@ bool BfModule::SlotVirtualMethod(BfMethodInstance* methodInstance, BfAmbiguityCo continue; } + if (iMethodIdx >= ifaceInst->mMethodInstanceGroups.mSize) + PopulateType(ifaceInst, BfPopulateType_DataAndMethods); + + if (iMethodIdx >= ifaceInst->mMethodInstanceGroups.mSize) + { + InternalError("Interface slotting error", methodInstance->mMethodDef->GetMutNode()); + break; + } + auto& iMethodGroup = ifaceInst->mMethodInstanceGroups[iMethodIdx]; auto iMethodInst = iMethodGroup.mDefault; if (iMethodInst == NULL)