From 51567c0513aaed7830e5f5474a625eb0a1475ad2 Mon Sep 17 00:00:00 2001 From: Jason Cobb Date: Thu, 15 Feb 2018 23:24:32 -0500 Subject: Change invalid (not exactly 160 bits long) address literal to error --- libsolidity/analysis/TypeChecker.cpp | 15 +++++++++++---- 1 file 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(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(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'. " + -- cgit v1.2.3