Skip to content

Commit

Permalink
Fixed initializer error for unknown-sized arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
bfiete committed Jun 25, 2020
1 parent 9ea5b72 commit 92e1898
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions IDEHelper/Compiler/BfExprEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
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)]);
failedAt.Add(depth);
Expand Down

0 comments on commit 92e1898

Please sign in to comment.