diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 3fa068491d9f..76c4b7c3f762 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -404,7 +404,13 @@ std::set Type::operatorDefiniti *identifierPath->annotation().referencedDeclaration ); auto const* functionType = dynamic_cast(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)) diff --git a/test/libsolidity/syntaxTests/operators/userDefined/operator_zero_param_alongside_valid_binding_no_ice.sol b/test/libsolidity/syntaxTests/operators/userDefined/operator_zero_param_alongside_valid_binding_no_ice.sol new file mode 100644 index 000000000000..7d011492540c --- /dev/null +++ b/test/libsolidity/syntaxTests/operators/userDefined/operator_zero_param_alongside_valid_binding_no_ice.sol @@ -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".