aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorJason Cobb <jason.e.cobb@gmail.com>2018-02-16 12:24:32 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-06-25 22:17:50 +0800
commit51567c0513aaed7830e5f5474a625eb0a1475ad2 (patch)
tree57f645169b441cd3c460ae05d2b708e4517fe7ef /libsolidity/analysis
parent3d88eca531109b8b19eabd9f33b9d860056e7754 (diff)
downloaddexon-solidity-51567c0513aaed7830e5f5474a625eb0a1475ad2.tar
dexon-solidity-51567c0513aaed7830e5f5474a625eb0a1475ad2.tar.gz
dexon-solidity-51567c0513aaed7830e5f5474a625eb0a1475ad2.tar.bz2
dexon-solidity-51567c0513aaed7830e5f5474a625eb0a1475ad2.tar.lz
dexon-solidity-51567c0513aaed7830e5f5474a625eb0a1475ad2.tar.xz
dexon-solidity-51567c0513aaed7830e5f5474a625eb0a1475ad2.tar.zst
dexon-solidity-51567c0513aaed7830e5f5474a625eb0a1475ad2.zip
Change invalid (not exactly 160 bits long) address literal to error
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 19e931f2..e50464f4 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -2287,10 +2287,17 @@ void TypeChecker::endVisit(Literal const& _literal)
if (_literal.looksLikeAddress())
{
- if (_literal.passesAddressChecksum())
- _literal.annotation().type = make_shared<IntegerType>(160, IntegerType::Modifier::Address);
- else
- m_errorReporter.warning(
+ // 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);
+
+ if (_literal.value().length() != 42) // "0x" + 40 hex digits
+ m_errorReporter.syntaxError(
+ _literal.location(),
+ "This looks like an address but is not exactly 20 bytes long. Current length is " +
+ to_string(_literal.value().length()) + " (should be 42)."
+ );
+ else if (!_literal.passesAddressChecksum())
+ 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'. " +