Преглед изворни кода

Fixed issue with global variable as sized array size

Brian Fiete пре 3 година
родитељ
комит
ff54f3ce9c
1 измењених фајлова са 6 додато и 3 уклоњено
  1. 6 3
      IDEHelper/Compiler/BfResolvedTypeUtils.cpp

+ 6 - 3
IDEHelper/Compiler/BfResolvedTypeUtils.cpp

@@ -3293,9 +3293,13 @@ int BfResolvedTypeSet::DoHash(BfTypeReference* typeRef, LookupContext* ctx, BfHa
 							ctx->mModule->Fail("Invalid use of inferred-sized array", sizeExpr);
 							ctx->mModule->Fail("Invalid use of inferred-sized array", sizeExpr);
 						}
 						}
 					}
 					}
+					else if (!BfIRBuilder::IsInt(constant->mTypeCode))
+					{
+						ctx->mFailed = true;
+						ctx->mModule->Fail("Array size not a constant value", arrayType->mParams[0]);
+					}
 					else
 					else
 					{
 					{
-						BF_ASSERT(BfIRBuilder::IsInt(constant->mTypeCode));
 						elementCount = (intptr)constant->mInt64;
 						elementCount = (intptr)constant->mInt64;
 						if (elementCount < 0)
 						if (elementCount < 0)
 						{
 						{
@@ -4362,13 +4366,12 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext*
 					return false;				
 					return false;				
 				
 				
 				auto constant = ctx->mModule->mBfIRBuilder->GetConstant(typedVal.mValue);
 				auto constant = ctx->mModule->mBfIRBuilder->GetConstant(typedVal.mValue);
-				if (constant->mConstType == BfConstType_Undef)
+				if ((constant->mConstType == BfConstType_Undef) || (!BfIRBuilder::IsInt(constant->mTypeCode)))
 				{
 				{
 					elementCount = -1; // Marker for undef
 					elementCount = -1; // Marker for undef
 				}
 				}
 				else
 				else
 				{
 				{
-					BF_ASSERT(BfIRBuilder::IsInt(constant->mTypeCode));
 					elementCount = (intptr)constant->mInt64;
 					elementCount = (intptr)constant->mInt64;
 					BF_ASSERT(elementCount >= 0); // Should have been caught in hash					
 					BF_ASSERT(elementCount >= 0); // Should have been caught in hash					
 				}
 				}