From ff54f3ce9cb9f405a8ae40dafa787a964dcf23ec Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Mon, 6 Dec 2021 11:39:19 -0800 Subject: [PATCH] Fixed issue with global variable as sized array size --- IDEHelper/Compiler/BfResolvedTypeUtils.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp index 9a328729..7b85a000 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp +++ b/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); } } + else if (!BfIRBuilder::IsInt(constant->mTypeCode)) + { + ctx->mFailed = true; + ctx->mModule->Fail("Array size not a constant value", arrayType->mParams[0]); + } else { - BF_ASSERT(BfIRBuilder::IsInt(constant->mTypeCode)); elementCount = (intptr)constant->mInt64; if (elementCount < 0) { @@ -4362,13 +4366,12 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext* return false; 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 } else { - BF_ASSERT(BfIRBuilder::IsInt(constant->mTypeCode)); elementCount = (intptr)constant->mInt64; BF_ASSERT(elementCount >= 0); // Should have been caught in hash }