aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis/ReferencesResolver.cpp
diff options
context:
space:
mode:
authorErik Kundt <bitshift@posteo.org>2018-09-22 06:18:22 +0800
committerErik Kundt <bitshift@posteo.org>2018-09-22 06:25:52 +0800
commitd821cbdff5a483b3f7a7bd07758bf5e11a7cd762 (patch)
tree8e6a7c5c5da3d62c811f432f0c6fb6fa0b5728e9 /libsolidity/analysis/ReferencesResolver.cpp
parentff5be1799088ca51fb51e9c86031bd2d88fe3bce (diff)
downloaddexon-solidity-d821cbdff5a483b3f7a7bd07758bf5e11a7cd762.tar.gz
dexon-solidity-d821cbdff5a483b3f7a7bd07758bf5e11a7cd762.tar.zst
dexon-solidity-d821cbdff5a483b3f7a7bd07758bf5e11a7cd762.zip
Moves length check to reference resolver.
Diffstat (limited to 'libsolidity/analysis/ReferencesResolver.cpp')
-rw-r--r--libsolidity/analysis/ReferencesResolver.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp
index 8a576e2e..30aa3d49 100644
--- a/libsolidity/analysis/ReferencesResolver.cpp
+++ b/libsolidity/analysis/ReferencesResolver.cpp
@@ -231,6 +231,8 @@ void ReferencesResolver::endVisit(Mapping const& _typeName)
void ReferencesResolver::endVisit(ArrayTypeName const& _typeName)
{
TypePointer baseType = _typeName.baseType().annotation().type;
+ auto arrayType = dynamic_cast<ArrayType const*>(baseType.get());
+ bool isFixedSizeArray = (arrayType && arrayType->isByteArray()) || !baseType->isDynamicallySized();
if (!baseType)
{
solAssert(!m_errorReporter.errors().empty(), "");
@@ -246,6 +248,8 @@ void ReferencesResolver::endVisit(ArrayTypeName const& _typeName)
RationalNumberType const* lengthType = dynamic_cast<RationalNumberType const*>(lengthTypeGeneric.get());
if (!lengthType || !lengthType->mobileType())
fatalTypeError(length->location(), "Invalid array length, expected integer literal or constant expression.");
+ else if (lengthType->isZero() && isFixedSizeArray)
+ fatalTypeError(length->location(), "Array with zero length specified.");
else if (lengthType->isFractional())
fatalTypeError(length->location(), "Array with fractional length specified.");
else if (lengthType->isNegative())