Browse Source

Sanity check for mid-compile deleted types

Brian Fiete 7 months ago
parent
commit
18f7a5bd09
1 changed files with 24 additions and 0 deletions
  1. 24 0
      IDEHelper/Compiler/BfModule.cpp

+ 24 - 0
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)