diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-06-25 22:25:21 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-06-25 22:25:21 +0800 |
commit | 6d9a091a8e0c7e5a958ff910c9f8dc828a39e0e4 (patch) | |
tree | a027ddad46f3c20ef7d3b013b230083895c81db5 /libsolidity | |
parent | c7f842d4cc860a8201a584cfbd43401b7ad271b4 (diff) | |
download | dexon-solidity-6d9a091a8e0c7e5a958ff910c9f8dc828a39e0e4.tar dexon-solidity-6d9a091a8e0c7e5a958ff910c9f8dc828a39e0e4.tar.gz dexon-solidity-6d9a091a8e0c7e5a958ff910c9f8dc828a39e0e4.tar.bz2 dexon-solidity-6d9a091a8e0c7e5a958ff910c9f8dc828a39e0e4.tar.lz dexon-solidity-6d9a091a8e0c7e5a958ff910c9f8dc828a39e0e4.tar.xz dexon-solidity-6d9a091a8e0c7e5a958ff910c9f8dc828a39e0e4.tar.zst dexon-solidity-6d9a091a8e0c7e5a958ff910c9f8dc828a39e0e4.zip |
Keep the 'if it not used as an address' helper message for all cases of address related warnings
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 14789979..b46d4849 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -2290,20 +2290,25 @@ void TypeChecker::endVisit(Literal const& _literal) // Assign type here if it even looks like an address. This prevents double error in 050 mode for invalid address _literal.annotation().type = make_shared<IntegerType>(160, IntegerType::Modifier::Address); + string msg; if (_literal.value().length() != 42) // "0x" + 40 hex digits // looksLikeAddress enforces that it is a hex literal starting with "0x" - m_errorReporter.syntaxError( - _literal.location(), + msg = "This looks like an address but is not exactly 40 hex digits. It is " + to_string(_literal.value().length() - 2) + - " hex digits." - ); + " hex digits."; else if (!_literal.passesAddressChecksum()) + { + msg = "This looks like an address but has an invalid checksum."; + if (!_literal.getChecksummedAddress().empty()) + msg += " Correct checksummed address: \"" + _literal.getChecksummedAddress() + "\"."; + } + + if (!msg.empty()) m_errorReporter.syntaxError( _literal.location(), - "This looks like an address but has an invalid checksum. " - "If this is not used as an address, please prepend '00'. " + - (!_literal.getChecksummedAddress().empty() ? "Correct checksummed address: '" + _literal.getChecksummedAddress() + "'. " : "") + + msg + + " If this is not used as an address, please prepend '00'. " + "For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals" ); } |