Compare categories instead of types in ContractCompiler(740)

This commit is contained in:
Jason Cobb 2020-04-27 15:01:01 -04:00
parent 55e34407d3
commit 8973732b74
No known key found for this signature in database
GPG Key ID: 2A3F6A6DCA1E8DED
2 changed files with 16 additions and 1 deletions

View File

@ -733,7 +733,10 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
{
case Type::Category::Bool:
case Type::Category::Address:
solAssert(*type == *variable->annotation().type, "");
// Either both the literal and the variable are bools, or they are both addresses.
// If they are both bools, comparing category is the same as comparing the types.
// If they are both addresses, compare category so that payable/nonpayable is not compared.
solAssert(type->category() == variable->annotation().type->category(), "");
value = type->literalValue(literal);
break;
case Type::Category::StringLiteral:

View File

@ -0,0 +1,12 @@
// Test for regression of https://github.com/ethereum/solidity/issues/8406
contract C {
address constant e = 0x1212121212121212121212121000002134593163;
function f() public returns (byte z) {
assembly { z := e }
}
}
// ----
// f() -> 0x00