aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis/ReferencesResolver.cpp
diff options
context:
space:
mode:
authorwadeAlexC <wade.alex.c@gmail.com>2017-10-03 05:59:39 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-10-04 05:01:58 +0800
commit73f17876e9a424f9519e3c4b4364139aaae7a62a (patch)
tree1880edd1aeb2108814773c6ca56333c988293e0b /libsolidity/analysis/ReferencesResolver.cpp
parentcfc4e5dde30daf63fdc78faa0e863965e167aff9 (diff)
downloaddexon-solidity-73f17876e9a424f9519e3c4b4364139aaae7a62a.tar.gz
dexon-solidity-73f17876e9a424f9519e3c4b4364139aaae7a62a.tar.zst
dexon-solidity-73f17876e9a424f9519e3c4b4364139aaae7a62a.zip
Better error message when using fractional number as array size expressions
Diffstat (limited to 'libsolidity/analysis/ReferencesResolver.cpp')
-rw-r--r--libsolidity/analysis/ReferencesResolver.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp
index a7fa908d..20016112 100644
--- a/libsolidity/analysis/ReferencesResolver.cpp
+++ b/libsolidity/analysis/ReferencesResolver.cpp
@@ -149,8 +149,10 @@ 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() || !lengthType->mobileType())
+ if (!lengthType || !lengthType->mobileType())
fatalTypeError(length->location(), "Invalid array length, expected integer literal.");
+ else if (lengthType->isFractional())
+ fatalTypeError(length->location(), "Array with fractional length specified.");
else if (lengthType->isNegative())
fatalTypeError(length->location(), "Array with negative length specified.");
else
@@ -347,4 +349,3 @@ void ReferencesResolver::fatalDeclarationError(SourceLocation const& _location,
m_errorOccurred = true;
m_errorReporter.fatalDeclarationError(_location, _description);
}
-