mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed initializer error for unknown-sized arrays
This commit is contained in:
parent
9ea5b72b65
commit
92e189826b
1 changed files with 7 additions and 2 deletions
|
@ -16097,9 +16097,14 @@ void BfExprEvaluator::InitializedSizedArray(BfSizedArrayType* arrayType, BfToken
|
||||||
_GetValues = [&](BfSizedArrayType* checkArrayType, BfTokenNode* openToken, const BfSizedArray<BfExpression*>& valueExprs, const BfSizedArray<BfTokenNode*>& commas, BfTokenNode* closeToken, bool ignore)
|
_GetValues = [&](BfSizedArrayType* checkArrayType, BfTokenNode* openToken, const BfSizedArray<BfExpression*>& valueExprs, const BfSizedArray<BfTokenNode*>& commas, BfTokenNode* closeToken, bool ignore)
|
||||||
{
|
{
|
||||||
int64 initCountDiff = (int)valueExprs.size() - checkArrayType->mElementCount;
|
int64 initCountDiff = (int)valueExprs.size() - checkArrayType->mElementCount;
|
||||||
if ((initCountDiff != 0) && (!failedAt.Contains(depth)))
|
if ((initCountDiff != 0) && (!valueExprs.IsEmpty()) && (!failedAt.Contains(depth)))
|
||||||
{
|
{
|
||||||
if (initCountDiff > 0)
|
if (checkArrayType->mElementCount == -1)
|
||||||
|
{
|
||||||
|
mModule->Fail("Initializers not supported for unknown-sized arrays", valueExprs[0]);
|
||||||
|
failedAt.Add(depth);
|
||||||
|
}
|
||||||
|
else if (initCountDiff > 0)
|
||||||
{
|
{
|
||||||
mModule->Fail(StrFormat("Too many initializers, expected %d fewer", initCountDiff), valueExprs[BF_MAX((int)checkArrayType->mElementCount, 0)]);
|
mModule->Fail(StrFormat("Too many initializers, expected %d fewer", initCountDiff), valueExprs[BF_MAX((int)checkArrayType->mElementCount, 0)]);
|
||||||
failedAt.Add(depth);
|
failedAt.Add(depth);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue