mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Keep the 'if it not used as an address' helper message for all cases of address related warnings
This commit is contained in:
parent
c7f842d4cc
commit
6d9a091a8e
@ -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"
|
||||
);
|
||||
}
|
||||
|
@ -5,4 +5,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (64-106): This looks like an address but has an invalid checksum. If this is not used as an address, please prepend '00'. Correct checksummed address: '0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
|
||||
// SyntaxError: (64-106): This looks like an address but has an invalid checksum. Correct checksummed address: "0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E". 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
|
||||
|
@ -5,4 +5,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (64-106): This looks like an address but has an invalid checksum. If this is not used as an address, please prepend '00'. Correct checksummed address: '0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
|
||||
// SyntaxError: (64-106): This looks like an address but has an invalid checksum. Correct checksummed address: "0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E". 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
|
||||
|
@ -5,4 +5,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (64-105): This looks like an address but is not exactly 40 hex digits. It is 39 hex digits.
|
||||
// SyntaxError: (64-105): This looks like an address but is not exactly 40 hex digits. It is 39 hex digits. 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
|
||||
|
@ -5,4 +5,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (64-107): This looks like an address but is not exactly 40 hex digits. It is 41 hex digits.
|
||||
// SyntaxError: (64-107): This looks like an address but is not exactly 40 hex digits. It is 41 hex digits. 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
|
||||
|
Loading…
Reference in New Issue
Block a user