Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions libsolidity/ast/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,16 @@ MemberList::MemberMap Type::attachedFunctions(Type const& _type, ASTNode const&
}
}
else
addFunction(
dynamic_cast<FunctionDefinition const&>(*declaration),
identifierPath->path().back()
);
{
auto const& functionDefinition = dynamic_cast<FunctionDefinition const&>(*declaration);
// Zero-parameter functions are rejected by TypeChecker::endVisit(UsingForDirective)
// with error 4731, but member resolution can run before the directive is visited
// when the call site precedes the directive in the contract body. Skip these here
// so addFunction() does not assert in withBoundFirstArgument() (#16610).
if (functionDefinition.parameters().empty())
continue;
addFunction(functionDefinition, identifierPath->path().back());
}
}

return members;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function zero() pure returns (uint) { return 0; }

contract C {
function f(uint z) pure external returns (uint) {
return z.zero();
}
using {zero} for uint;
}
// ----
// TypeError 9582: (133-139): Member "zero" not found or not visible after argument-dependent lookup in uint256.
// TypeError 4731: (160-164): The function "zero" does not have any parameters, and therefore cannot be attached to the type "uint256".