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
8 changes: 7 additions & 1 deletion libsolidity/ast/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,13 @@ std::set<FunctionDefinition const*, ASTNode::CompareByID> Type::operatorDefiniti
*identifierPath->annotation().referencedDeclaration
);
auto const* functionType = dynamic_cast<FunctionType const*>(functionDefinition.typeWhenAttached());
solAssert(functionType && !functionType->parameterTypes().empty());
solAssert(functionType);
// Zero-parameter functions are rejected by TypeChecker::endVisit(UsingForDirective)
// with error 4731, but that fatal fires per-binding and the matching scan below
// still revisits sibling bindings. Skip them here so that we do not assert on an
// already-reported invalid binding (#16613).
if (functionType->parameterTypes().empty())
continue;

size_t parameterCount = functionDefinition.parameterList().parameters().size();
if (*this == *functionType->parameterTypes().front() && (_unary ? parameterCount == 1 : parameterCount == 2))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type T is int256;
function f(T a, T b) pure returns (T) {}
function g() pure returns (T) {}
using {f as -, g as -} for T global;
// ----
// TypeError 4731: (107-108): The function "g" does not have any parameters, and therefore cannot be attached to the type "T".