aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis/ReferencesResolver.cpp
diff options
context:
space:
mode:
authorErik Kundt <bitshift@posteo.org>2018-09-22 09:07:12 +0800
committerErik Kundt <bitshift@posteo.org>2018-09-22 09:07:12 +0800
commite6d87e54c8cdf7c9111707770e995b486ec82460 (patch)
tree1aadf5a6434ab93ea38c3fdaf6714d8928a0bb72 /libsolidity/analysis/ReferencesResolver.cpp
parent13a5890cc36d3ca5e9b4cd53c21dd4616c4eb55b (diff)
downloaddexon-solidity-e6d87e54c8cdf7c9111707770e995b486ec82460.tar.gz
dexon-solidity-e6d87e54c8cdf7c9111707770e995b486ec82460.tar.zst
dexon-solidity-e6d87e54c8cdf7c9111707770e995b486ec82460.zip
Simplifies zero-length check for fixed-size arrays.
Diffstat (limited to 'libsolidity/analysis/ReferencesResolver.cpp')
-rw-r--r--libsolidity/analysis/ReferencesResolver.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp
index 30aa3d49..6217c5d1 100644
--- a/libsolidity/analysis/ReferencesResolver.cpp
+++ b/libsolidity/analysis/ReferencesResolver.cpp
@@ -231,8 +231,6 @@ 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(), "");
@@ -243,12 +241,14 @@ void ReferencesResolver::endVisit(ArrayTypeName const& _typeName)
if (Expression const* length = _typeName.length())
{
TypePointer lengthTypeGeneric = length->annotation().type;
+ auto arrayType = dynamic_cast<ArrayType const*>(baseType.get());
+ bool isByteOrFixedSizeArray = (arrayType && arrayType->isByteArray()) || !baseType->isDynamicallySized();
if (!lengthTypeGeneric)
lengthTypeGeneric = ConstantEvaluator(m_errorReporter).evaluate(*length);
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)
+ else if (lengthType->isZero() && isByteOrFixedSizeArray)
fatalTypeError(length->location(), "Array with zero length specified.");
else if (lengthType->isFractional())
fatalTypeError(length->location(), "Array with fractional length specified.");