mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-15 06:44:10 +02:00
Fixed issue with global variable as sized array size
This commit is contained in:
parent
df94a61f48
commit
ff54f3ce9c
1 changed files with 6 additions and 3 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue