diff --git a/test/libsolidity/syntaxTests/functionTypes/call_value_on_non_payable_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/call_value_on_non_payable_function_type.sol index dac7908fe..87c3b05b1 100644 --- a/test/libsolidity/syntaxTests/functionTypes/call_value_on_non_payable_function_type.sol +++ b/test/libsolidity/syntaxTests/functionTypes/call_value_on_non_payable_function_type.sol @@ -4,3 +4,5 @@ contract C { x.value(2)(); } } +// ---- +// TypeError: (94-101): Member "value" not found or not visible after argument-dependent lookup in function (uint256) external returns (uint256) - did you forget the "payable" modifier? diff --git a/test/libsolidity/syntaxTests/functionTypes/delete_external_function_type_invalid.sol b/test/libsolidity/syntaxTests/functionTypes/delete_external_function_type_invalid.sol index e3bf2dee9..2711dae82 100644 --- a/test/libsolidity/syntaxTests/functionTypes/delete_external_function_type_invalid.sol +++ b/test/libsolidity/syntaxTests/functionTypes/delete_external_function_type_invalid.sol @@ -3,3 +3,5 @@ contract C { delete this.f; } } +// ---- +// TypeError: (54-60): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol index 40c0c86f8..a6fe6c225 100644 --- a/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol +++ b/test/libsolidity/syntaxTests/functionTypes/delete_function_type.sol @@ -12,3 +12,6 @@ contract C { delete g; } } +// ---- +// Warning: (157-162): Use of the "var" keyword is deprecated. +// Warning: (212-217): Use of the "var" keyword is deprecated. diff --git a/test/libsolidity/syntaxTests/functionTypes/delete_function_type_invalid.sol b/test/libsolidity/syntaxTests/functionTypes/delete_function_type_invalid.sol index c2c77be0e..60da19e40 100644 --- a/test/libsolidity/syntaxTests/functionTypes/delete_function_type_invalid.sol +++ b/test/libsolidity/syntaxTests/functionTypes/delete_function_type_invalid.sol @@ -3,3 +3,5 @@ contract C { delete f; } } +// ---- +// TypeError: (54-55): Expression has to be an lvalue. diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_to_function_type_calldata_parameter.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_to_function_type_calldata_parameter.sol index cbf90e403..eb4f0693e 100644 --- a/test/libsolidity/syntaxTests/functionTypes/external_function_to_function_type_calldata_parameter.sol +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_to_function_type_calldata_parameter.sol @@ -1,7 +1,10 @@ +// This is a test that checks that the type of the `bytes` parameter is +// correctly changed from its own type `bytes calldata` to `bytes memory` +// when converting to a function type. contract C { - function f(function(bytes memory) external g) public { } - function callback(bytes) external {} - function g() public { + function f(function(bytes memory) pure external /*g*/) pure public { } + function callback(bytes) pure external {} + function g() view public { f(this.callback); } } diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_returning_internal.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_returning_internal.sol index c4f56b41d..8b14d3dc5 100644 --- a/test/libsolidity/syntaxTests/functionTypes/external_function_type_returning_internal.sol +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_returning_internal.sol @@ -1,3 +1,5 @@ contract C { function() external returns (function () internal) x; } +// ---- +// TypeError: (46-67): Internal type cannot be used for external function type. diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_taking_internal.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_taking_internal.sol index c3ba80a3b..3e264c8cc 100644 --- a/test/libsolidity/syntaxTests/functionTypes/external_function_type_taking_internal.sol +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_taking_internal.sol @@ -1,3 +1,5 @@ contract C { function(function () internal) external x; } +// ---- +// TypeError: (26-47): Internal type cannot be used for external function type. diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address.sol index 5f4d40650..b86425dbc 100644 --- a/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address.sol +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_address.sol @@ -1,5 +1,5 @@ contract C { - function f() public returns (address) { + function f() public view returns (address) { return address(this.f); } } diff --git a/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_uint.sol b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_uint.sol index e47abefbf..f42872238 100644 --- a/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_uint.sol +++ b/test/libsolidity/syntaxTests/functionTypes/external_function_type_to_uint.sol @@ -3,3 +3,5 @@ contract C { return uint(this.f); } } +// ---- +// TypeError: (69-81): Explicit type conversion not allowed from "function () external returns (uint256)" to "uint256". diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type.sol b/test/libsolidity/syntaxTests/functionTypes/function_type.sol index a879e351c..23d501367 100644 --- a/test/libsolidity/syntaxTests/functionTypes/function_type.sol +++ b/test/libsolidity/syntaxTests/functionTypes/function_type.sol @@ -1,5 +1,6 @@ contract C { - function f() public { + function f() pure public { function(uint) returns (uint) x; + x; } } diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_arrays.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_arrays.sol index c402dbff2..ec23d637a 100644 --- a/test/libsolidity/syntaxTests/functionTypes/function_type_arrays.sol +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_arrays.sol @@ -1,7 +1,7 @@ contract C { function(uint) external returns (uint)[] public x; function(uint) internal returns (uint)[10] y; - function f() public { + function f() view public { function(uint) returns (uint)[10] memory a; function(uint) returns (uint)[10] storage b = y; function(uint) external returns (uint)[] memory c; diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_parameter.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_parameter.sol index c787e6f07..da66ec8a2 100644 --- a/test/libsolidity/syntaxTests/functionTypes/function_type_parameter.sol +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_parameter.sol @@ -1,5 +1,7 @@ contract C { + uint x; function f(function(uint) external returns (uint) g) public returns (function(uint) external returns (uint)) { + x = 2; return g; } } diff --git a/test/libsolidity/syntaxTests/functionTypes/function_type_returned.sol b/test/libsolidity/syntaxTests/functionTypes/function_type_returned.sol index 0590fad4d..9cd313c8f 100644 --- a/test/libsolidity/syntaxTests/functionTypes/function_type_returned.sol +++ b/test/libsolidity/syntaxTests/functionTypes/function_type_returned.sol @@ -1,5 +1,5 @@ contract C { - function f() public returns (function(uint) external returns (uint) g) { + function f() public pure returns (function(uint) pure external returns (uint) g) { return g; } } diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter.sol index 3103001d2..fa92d5597 100644 --- a/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter.sol +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter.sol @@ -1,4 +1,8 @@ +// It should not be possible to give internal functions +// as parameters to external functions. contract C { function f(function(uint) internal returns (uint) x) public { } } +// ---- +// TypeError: (124-164): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_external.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_external.sol index 7856d62d2..b37fb285c 100644 --- a/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_external.sol +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_external.sol @@ -2,3 +2,5 @@ library L { function f(function(uint) internal returns (uint) x) public { } } +// ---- +// TypeError: (27-67): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_internal.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_internal.sol index 13d6d03d8..7ffa447ea 100644 --- a/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_internal.sol +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_as_external_parameter_in_library_internal.sol @@ -1,4 +1,4 @@ library L { - function f(function(uint) internal returns (uint) x) internal { + function f(function(uint) internal returns (uint) /*x*/) pure internal { } } diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_returned_from_public_function.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_returned_from_public_function.sol index e836a6cc6..41fcd0a44 100644 --- a/test/libsolidity/syntaxTests/functionTypes/internal_function_returned_from_public_function.sol +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_returned_from_public_function.sol @@ -1,4 +1,7 @@ +// It should not be possible to return internal functions from external functions. contract C { function f() public returns (function(uint) internal returns (uint) x) { } } +// ---- +// TypeError: (129-169): Internal or recursive type is not allowed for public or external functions. diff --git a/test/libsolidity/syntaxTests/functionTypes/internal_function_type_to_address.sol b/test/libsolidity/syntaxTests/functionTypes/internal_function_type_to_address.sol index 4a3f02c1f..b75a0d436 100644 --- a/test/libsolidity/syntaxTests/functionTypes/internal_function_type_to_address.sol +++ b/test/libsolidity/syntaxTests/functionTypes/internal_function_type_to_address.sol @@ -3,3 +3,5 @@ contract C { return address(f); } } +// ---- +// TypeError: (72-82): Explicit type conversion not allowed from "function () returns (address)" to "address". diff --git a/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type.sol index 69efaad4b..a7cb9d92a 100644 --- a/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type.sol +++ b/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type.sol @@ -1,3 +1,5 @@ contract C { function (uint) internal payable returns (uint) x; } +// ---- +// TypeError: (17-66): Only external function types can be payable. diff --git a/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type_is_not_fatal.sol b/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type_is_not_fatal.sol index fb84f9ca4..5c6dc0561 100644 --- a/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type_is_not_fatal.sol +++ b/test/libsolidity/syntaxTests/functionTypes/payable_internal_function_type_is_not_fatal.sol @@ -1,7 +1,9 @@ contract C { function (uint) internal payable returns (uint) x; - function g() { + function g() public { x = g; } } +// ---- +// TypeError: (17-66): Only external function types can be payable. diff --git a/test/libsolidity/syntaxTests/functionTypes/private_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/private_function_type.sol index d15430d23..9d4f0a097 100644 --- a/test/libsolidity/syntaxTests/functionTypes/private_function_type.sol +++ b/test/libsolidity/syntaxTests/functionTypes/private_function_type.sol @@ -3,3 +3,5 @@ contract C { function(uint) private returns (uint) x; } } +// ---- +// TypeError: (47-86): Invalid visibility, can only be "external" or "internal". diff --git a/test/libsolidity/syntaxTests/functionTypes/public_function_type.sol b/test/libsolidity/syntaxTests/functionTypes/public_function_type.sol index ecc2493ad..756766d3b 100644 --- a/test/libsolidity/syntaxTests/functionTypes/public_function_type.sol +++ b/test/libsolidity/syntaxTests/functionTypes/public_function_type.sol @@ -3,3 +3,5 @@ contract C { function(uint) public returns (uint) x; } } +// ---- +// TypeError: (47-85): Invalid visibility, can only be "external" or "internal". diff --git a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_parameters_with_names.sol b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_parameters_with_names.sol index 44417f256..072c7eb71 100644 --- a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_parameters_with_names.sol +++ b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_parameters_with_names.sol @@ -1,3 +1,5 @@ contract C { function(uint a) f; } +// ---- +// Warning: (26-32): Naming function type parameters is deprecated. diff --git a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol index f8c21fa80..67a74e546 100644 --- a/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol +++ b/test/libsolidity/syntaxTests/functionTypes/warn_function_type_return_parameters_with_names.sol @@ -1,3 +1,5 @@ contract C { function(uint) returns (bool ret) f; } +// ---- +// Warning: (41-49): Naming function type return parameters is deprecated.