diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index c613dd796d98..5449631a26ec 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -2348,7 +2348,16 @@ void TypeChecker::typeCheckStringConcatFunction( { solAssert(_functionType); solAssert(_functionType->kind() == FunctionType::Kind::StringConcat); - solAssert(_functionCall.names().empty()); + + if (!_functionCall.names().empty()) + { + m_errorReporter.typeError( + 4903_error, + _functionCall.location(), + "Named arguments cannot be used with string.concat()." + ); + return; + } typeCheckFunctionGeneralChecks(_functionCall, _functionType); @@ -2375,7 +2384,16 @@ void TypeChecker::typeCheckBytesConcatFunction( { solAssert(_functionType); solAssert(_functionType->kind() == FunctionType::Kind::BytesConcat); - solAssert(_functionCall.names().empty()); + + if (!_functionCall.names().empty()) + { + m_errorReporter.typeError( + 8145_error, + _functionCall.location(), + "Named arguments cannot be used with bytes.concat()." + ); + return; + } typeCheckFunctionGeneralChecks(_functionCall, _functionType); diff --git a/test/libsolidity/syntaxTests/array/concat/bytes_concat_named_args.sol b/test/libsolidity/syntaxTests/array/concat/bytes_concat_named_args.sol new file mode 100644 index 000000000000..7288a054fa37 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/concat/bytes_concat_named_args.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + bytes.concat({x: "abc", y: hex"00"}); + } +} +// ---- +// TypeError 8145: (52-88): Named arguments cannot be used with bytes.concat(). diff --git a/test/libsolidity/syntaxTests/string/concat/string_concat_named_args.sol b/test/libsolidity/syntaxTests/string/concat/string_concat_named_args.sol new file mode 100644 index 000000000000..48e50826bc95 --- /dev/null +++ b/test/libsolidity/syntaxTests/string/concat/string_concat_named_args.sol @@ -0,0 +1,7 @@ +contract C { + function f() public pure { + string.concat({x: "abc", y: "def"}); + } +} +// ---- +// TypeError 4903: (52-87): Named arguments cannot be used with string.concat().