1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-14 22:34:09 +02:00

Fixed issue with global variable as sized array size

This commit is contained in:
Brian Fiete 2021-12-06 11:39:19 -08:00
parent df94a61f48
commit ff54f3ce9c

View file

@ -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
} }