Validate array length in type checker

This commit is contained in:
Alex Beregszaszi
2017-09-29 16:44:00 +01:00
parent f3fe043cc1
commit b1741b7735
3 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -149,7 +149,7 @@ void ReferencesResolver::endVisit(ArrayTypeName const& _typeName)
if (!length->annotation().type)
ConstantEvaluator e(*length);
auto const* lengthType = dynamic_cast<RationalNumberType const*>(length->annotation().type.get());
if (!lengthType || lengthType->isFractional())
if (!lengthType || lengthType->isFractional() || !lengthType->mobileType())
fatalTypeError(length->location(), "Invalid array length, expected integer literal.");
else if (lengthType->isNegative())
fatalTypeError(length->location(), "Array with negative length specified.");