aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-06-26 15:49:45 +0800
committerchriseth <chris@ethereum.org>2017-06-28 21:02:25 +0800
commitc3e5d6b7ef64f7924754d1b0a1c5577e038e7bf4 (patch)
tree4bd915cb0c24ee403e4bd54d258b5695ac7ac120 /libsolidity
parenta895f2dccb7f0dc22a01bd97fbf15e568deb38b0 (diff)
downloaddexon-solidity-c3e5d6b7ef64f7924754d1b0a1c5577e038e7bf4.tar
dexon-solidity-c3e5d6b7ef64f7924754d1b0a1c5577e038e7bf4.tar.gz
dexon-solidity-c3e5d6b7ef64f7924754d1b0a1c5577e038e7bf4.tar.bz2
dexon-solidity-c3e5d6b7ef64f7924754d1b0a1c5577e038e7bf4.tar.lz
dexon-solidity-c3e5d6b7ef64f7924754d1b0a1c5577e038e7bf4.tar.xz
dexon-solidity-c3e5d6b7ef64f7924754d1b0a1c5577e038e7bf4.tar.zst
dexon-solidity-c3e5d6b7ef64f7924754d1b0a1c5577e038e7bf4.zip
Give min and max values in warning message.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 1c91a2b0..b276a2d4 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -964,9 +964,17 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement)
{
int numBits = type->numBits();
bool isSigned = type->isSigned();
+ string minValue;
+ string maxValue;
if (isSigned)
+ {
numBits--;
- extension = ", which can hold values up to " + string((u256(1) << numBits) - 1);
+ minValue = "-" + bigint(bigint(1) << numBits).str();
+ }
+ else
+ minValue = "0";
+ maxValue = bigint((bigint(1) << numBits) - 1).str();
+ extension = ", which can hold values between " + minValue + " and " + maxValue;
}
else
solAssert(dynamic_cast<FixedPointType const*>(var.annotation().type.get()), "Unknown type.");