Merge pull request #8791 from random-internet-cat/fix-8406

Fix broken assertion in ContractCompiler
This commit is contained in:
chriseth 2020-04-28 19:46:30 +02:00 committed by GitHub
commit cc3992452f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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