2
0
Эх сурвалжийг харах

Fixed issue where we allowed multiple semicolons at end of if statements

Brian Fiete 5 жил өмнө
parent
commit
2c30afbfcf

+ 10 - 0
IDEHelper/Compiler/BfAst.cpp

@@ -738,6 +738,16 @@ bool BfAstNode::IsMissingSemicolon()
 {
 	if (auto deferStmt = BfNodeDynCast<BfDeferStatement>(this))
 		return BfNodeDynCastExact<BfBlock>(deferStmt->mTargetNode) == NULL;
+	if (auto stmt = BfNodeDynCast<BfCompoundStatement>(this))
+	{
+		if (auto repeatStmt = BfNodeDynCast<BfRepeatStatement>(this))
+		{
+			if (repeatStmt->mWhileToken == NULL)
+				return false;
+		}
+		else
+			return false;
+	}
 	if (auto stmt = BfNodeDynCast<BfStatement>(this))
 		return stmt->mTrailingSemicolon == NULL;
 

+ 2 - 2
IDEHelper/Compiler/BfCompiler.cpp

@@ -3891,8 +3891,8 @@ void BfCompiler::ProcessAutocompleteTempType()
 						if (fieldInstance->mConstIdx != -1)
 						{													
 							auto constant = typeInst->mConstHolder->GetConstantById(fieldInstance->mConstIdx);
-							auto retVal = module->ConstantToCurrent(constant, typeInst->mConstHolder, typeInst);
-							BfTypedValue typedValue = BfTypedValue(retVal, typeInst);
+							auto retVal = module->ConstantToCurrent(constant, typeInst->mConstHolder, fieldInstance->mResolvedType);
+							BfTypedValue typedValue = BfTypedValue(retVal, fieldInstance->mResolvedType);
 							autoComplete->CheckResult(fieldDef->GetRefNode(), typedValue);							
 						}
 					}

+ 16 - 5
IDEHelper/Compiler/BfExprEvaluator.cpp

@@ -1176,12 +1176,23 @@ bool BfMethodMatcher::CheckMethod(BfTypeInstance* targetTypeInstance, BfTypeInst
 		(targetTypeInstance != NULL) && (targetTypeInstance->IsObject()))
 	{
 		mModule->PopulateType(targetTypeInstance, BfPopulateType_DataAndMethods);
-		BfVirtualMethodEntry& vEntry = targetTypeInstance->mVirtualMethodTable[methodInstance->mVirtualTableIdx];
-		auto implMethod = (BfMethodInstance*)vEntry.mImplementingMethod;
-		if (implMethod != methodInstance)
+		if ((methodInstance->mVirtualTableIdx < targetTypeInstance->mVirtualMethodTable.mSize) && (methodInstance->mVirtualTableIdx >= 0))
 		{
-			SetAndRestoreValue<bool> prevBypassVirtual(mBypassVirtual, true);
-			return CheckMethod(targetTypeInstance, implMethod->GetOwner(), implMethod->mMethodDef, isFailurePass);
+			BfVirtualMethodEntry& vEntry = targetTypeInstance->mVirtualMethodTable[methodInstance->mVirtualTableIdx];
+			auto implMethod = (BfMethodInstance*)vEntry.mImplementingMethod;
+			if (implMethod != methodInstance)
+			{
+				SetAndRestoreValue<bool> prevBypassVirtual(mBypassVirtual, true);
+				return CheckMethod(targetTypeInstance, implMethod->GetOwner(), implMethod->mMethodDef, isFailurePass);
+			}
+		}
+		else
+		{
+			// Being in autocomplete mode is the only excuse for not having the virtual method table slotted
+			if ((!mModule->mCompiler->IsAutocomplete()) && (!targetTypeInstance->mTypeFailed))
+			{
+				mModule->AssertErrorState();
+			}
 		}
 	}
 

+ 3 - 1
IDEHelper/Compiler/BfParser.cpp

@@ -3507,7 +3507,9 @@ BF_EXPORT const char* BF_CALLTYPE BfParser_GetDebugExpressionAt(BfParser* bfPars
 
 	if ((exprNode->IsA<BfMethodDeclaration>()) ||
 		(exprNode->IsA<BfBlock>()) ||
-		(exprNode->IsA<BfStatement>()))
+		(exprNode->IsA<BfStatement>()) ||
+		(exprNode->IsA<BfTokenNode>())
+		)
 	{
 		return NULL;
 	}