diff options
Diffstat (limited to 'test/libsolidity/syntaxTests/specialFunctions')
5 files changed, 20 insertions, 6 deletions
diff --git a/test/libsolidity/syntaxTests/specialFunctions/single_non_bytes_arg.sol b/test/libsolidity/syntaxTests/specialFunctions/single_non_bytes_arg.sol new file mode 100644 index 00000000..3f8e3014 --- /dev/null +++ b/test/libsolidity/syntaxTests/specialFunctions/single_non_bytes_arg.sol @@ -0,0 +1,12 @@ +contract C { + function f() pure public { + g(keccak256(uint(2))); + g(sha256(uint(2))); + g(ripemd160(uint(2))); + } + function g(bytes32) pure internal {} +} +// ---- +// Warning: (54-72): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. The provided argument of type uint256 is not implicitly convertible to expected type bytes memory. +// Warning: (85-100): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. The provided argument of type uint256 is not implicitly convertible to expected type bytes memory. +// Warning: (113-131): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. The provided argument of type uint256 is not implicitly convertible to expected type bytes memory. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol index c98d7a57..b94a4391 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_internal_functions.sol @@ -1,11 +1,11 @@ contract C { function f() public pure { - bytes32 h = keccak256(keccak256, f, this.f.gas, block.blockhash); + bytes32 h = keccak256(abi.encodePacked(keccak256, f, this.f.gas, block.blockhash)); h; } } // ---- -// TypeError: (74-83): This type cannot be encoded. -// TypeError: (85-86): This type cannot be encoded. -// TypeError: (88-98): This type cannot be encoded. -// TypeError: (100-115): This type cannot be encoded. +// TypeError: (91-100): This type cannot be encoded. +// TypeError: (102-103): This type cannot be encoded. +// TypeError: (105-115): This type cannot be encoded. +// TypeError: (117-132): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol index fa910260..05f5db0b 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs.sol @@ -9,5 +9,6 @@ contract C { } } // ---- +// Warning: (132-144): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. // TypeError: (139-140): This type cannot be encoded. // TypeError: (142-143): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol index 1187ce4a..977a7d73 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_with_unspecified_encoding_structs_abiv2.sol @@ -12,5 +12,6 @@ contract C { } // ---- // Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments. +// Warning: (167-179): This function only accepts a single "bytes" argument. Please use "abi.encodePacked(...)" or a similar function to encode the data. // TypeError: (174-175): This type cannot be encoded. // TypeError: (177-178): This type cannot be encoded. diff --git a/test/libsolidity/syntaxTests/specialFunctions/types_without_encoding_problems.sol b/test/libsolidity/syntaxTests/specialFunctions/types_without_encoding_problems.sol index c8364548..d890e35f 100644 --- a/test/libsolidity/syntaxTests/specialFunctions/types_without_encoding_problems.sol +++ b/test/libsolidity/syntaxTests/specialFunctions/types_without_encoding_problems.sol @@ -2,7 +2,7 @@ contract C { uint[3] sarr; function f() view public { uint[3] memory arr; - bytes32 h = keccak256(this.f, arr, sarr); + bytes32 h = keccak256(abi.encodePacked(this.f, arr, sarr)); h; } } |