mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow conversions from literals to payable address
To get a payable address, one has to go through address. For example, `payable(address(0))`.
This commit is contained in:
parent
9bd778d728
commit
e1a95cfd42
@ -1768,7 +1768,10 @@ TypePointer TypeChecker::typeCheckTypeConversionAndRetrieveReturnType(
|
||||
if (addressType->stateMutability() != StateMutability::Payable)
|
||||
{
|
||||
bool payable = false;
|
||||
if (argType->category() != Type::Category::Address)
|
||||
if (
|
||||
argType->category() != Type::Category::Address &&
|
||||
argType->category() != Type::Category::RationalNumber
|
||||
)
|
||||
payable = argType->isExplicitlyConvertibleTo(*TypeProvider::payableAddress());
|
||||
resultType = payable ? TypeProvider::payableAddress() : TypeProvider::address();
|
||||
}
|
||||
@ -3314,7 +3317,7 @@ void TypeChecker::endVisit(Literal const& _literal)
|
||||
if (_literal.looksLikeAddress())
|
||||
{
|
||||
// Assign type here if it even looks like an address. This prevents double errors for invalid addresses
|
||||
_literal.annotation().type = TypeProvider::payableAddress();
|
||||
_literal.annotation().type = TypeProvider::address();
|
||||
|
||||
string msg;
|
||||
if (_literal.valueWithoutUnderscores().length() != 42) // "0x" + 40 hex digits
|
||||
|
Loading…
Reference in New Issue
Block a user