Merge pull request #11476 from ethereum/fix-ice-on-library-bound-to-literal

Fix ICE in IR when a library is bound to a literal
This commit is contained in:
chriseth 2021-06-03 08:58:00 +02:00 committed by GitHub
commit 93936129f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 13 deletions

View File

@ -1576,19 +1576,6 @@ void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess)
if (memberFunctionType && memberFunctionType->bound()) if (memberFunctionType && memberFunctionType->bound())
{ {
solAssert((set<Type::Category>{
Type::Category::Contract,
Type::Category::Bool,
Type::Category::Integer,
Type::Category::Address,
Type::Category::Function,
Type::Category::Struct,
Type::Category::Enum,
Type::Category::Mapping,
Type::Category::Array,
Type::Category::FixedBytes,
}).count(objectCategory) > 0, "");
define(IRVariable(_memberAccess).part("self"), _memberAccess.expression()); define(IRVariable(_memberAccess).part("self"), _memberAccess.expression());
solAssert(*_memberAccess.annotation().requiredLookup == VirtualLookup::Static, ""); solAssert(*_memberAccess.annotation().requiredLookup == VirtualLookup::Static, "");
if (memberFunctionType->kind() == FunctionType::Kind::Internal) if (memberFunctionType->kind() == FunctionType::Kind::Internal)

View File

@ -0,0 +1,26 @@
library L {
function double(uint a) internal pure returns (uint) {
return a * 2;
}
function double(bytes memory a) internal pure returns (bytes memory) {
return bytes.concat(a, a);
}
}
contract C {
using L for *;
function double42() public returns (uint) {
return 42.double();
}
function doubleABC() public returns (bytes memory) {
return "abc".double();
}
}
// ====
// compileViaYul: also
// ----
// double42() -> 84
// doubleABC() -> 0x20, 6, "abcabc"