Relax delegatecall type restriction plus test

This commit is contained in:
Nikola Matic 2023-07-18 13:55:46 +02:00
parent 110e2a656d
commit 82cb5338a9
3 changed files with 17 additions and 6 deletions

View File

@ -3423,12 +3423,10 @@ MemberList::MemberMap FunctionType::nativeMembers(ASTNode const* _scope) const
}
case Kind::DelegateCall:
{
auto const* functionDefinition = dynamic_cast<FunctionDefinition const*>(m_declaration);
solAssert(functionDefinition, "");
solAssert(functionDefinition->visibility() != Visibility::Private, "");
if (functionDefinition->visibility() != Visibility::Internal)
if (auto const* functionDefinition = dynamic_cast<FunctionDefinition const*>(m_declaration))
{
auto const* contract = dynamic_cast<ContractDefinition const*>(m_declaration->scope());
solAssert(functionDefinition->visibility() > Visibility::Internal, "");
auto const *contract = dynamic_cast<ContractDefinition const*>(m_declaration->scope());
solAssert(contract, "");
solAssert(contract->isLibrary(), "");
return {{"selector", TypeProvider::fixedBytes(4)}};

View File

@ -8,4 +8,5 @@ contract C {
}
}
// ----
// TypeError 1080: (117-130): True expression's type function D.f() does not match false expression's type function D.g().
// TypeError 9717: (121-124): Invalid mobile type in true expression.
// TypeError 3703: (127-130): Invalid mobile type in false expression.

View File

@ -0,0 +1,12 @@
library L {
function f() external {}
}
contract C {
function test() public {
(true ? L.f : L.f).selector;
}
}
// ----
// TypeError 9582: (94-121): Member "selector" not found or not visible after argument-dependent lookup in function ().