Update tests.

This commit is contained in:
chriseth 2018-08-07 19:12:49 +02:00
parent 16de7a0493
commit 13905a2094
62 changed files with 179 additions and 113 deletions

View File

@ -83,7 +83,7 @@
"id" : 3,
"name" : "",
"nodeType" : "VariableDeclaration",
"scope" : 16,
"scope" : 5,
"src" : "61:4:1",
"stateVariable" : false,
"storageLocation" : "default",
@ -167,7 +167,7 @@
"id" : 10,
"name" : "",
"nodeType" : "VariableDeclaration",
"scope" : 16,
"scope" : 12,
"src" : "113:4:1",
"stateVariable" : false,
"storageLocation" : "default",

View File

@ -1 +1,3 @@
contract C { function f(function() external payable returns (uint) x) returns (function() external view returns (uint)) {} }
// ----

View File

@ -100,7 +100,7 @@
{
"constant" : false,
"name" : "",
"scope" : 16,
"scope" : 5,
"stateVariable" : false,
"storageLocation" : "default",
"type" : "uint256",
@ -191,7 +191,7 @@
{
"constant" : false,
"name" : "",
"scope" : 16,
"scope" : 12,
"stateVariable" : false,
"storageLocation" : "default",
"type" : "uint256",

View File

@ -4,4 +4,5 @@ contract C {
}
}
// ----
// DeclarationError: (28-45): The "constant" keyword can only be used for state variables.
// TypeError: (69-72): Invalid array length, expected integer literal or constant expression.

View File

@ -1,11 +1,4 @@
library L {
struct Nested { uint y; }
// data location specifier in function signature should be optional even if there are multiple choices
function a(function(Nested) external returns (uint)[] storage) external pure {}
function b(function(Nested calldata) external returns (uint)[] storage) external pure {}
function c(function(Nested memory) external returns (uint)[] storage) external pure {}
function d(function(Nested storage) external returns (uint)[] storage) external pure {}
}
// ----
// TypeError: (441-447): Location has to be calldata or memory for function type of external function. Remove the data location keyword to fix this error.

View File

@ -0,0 +1,9 @@
library L {
struct Nested { uint y; }
function b(function(Nested calldata) external returns (uint)[] storage) external pure {}
function d(function(Nested storage) external returns (uint)[] storage) external pure {}
}
// ----
// TypeError: (66-72): Data location must be "memory" for parameter in function, but "calldata" was given.
// TypeError: (159-165): Data location must be "memory" for parameter in function, but "storage" was given.

View File

@ -2,4 +2,4 @@ contract C {
function i() external pure returns(uint[]) {}
}
// ----
// TypeError: (52-58): Storage location must be "memory" for parameter in external function, but none was given.
// TypeError: (52-58): Data location must be "memory" for return parameter in function, but none was given.

View File

@ -2,4 +2,4 @@ contract test {
function f(bytes memory) external;
}
// ----
// TypeError: (31-36): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
// TypeError: (31-36): Data location must be "calldata" for parameter in external function, but "memory" was given.

View File

@ -2,4 +2,4 @@ contract test {
function f(bytes storage) external;
}
// ----
// TypeError: (31-36): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
// TypeError: (31-36): Data location must be "calldata" for parameter in external function, but "storage" was given.

View File

@ -1,5 +0,0 @@
library test {
function f(bytes calldata) public;
}
// ----
// TypeError: (30-35): Location cannot be calldata for non-external functions (remove the "calldata" keyword).

View File

@ -2,4 +2,4 @@ contract test {
function f(bytes4 memory) public;
}
// ----
// TypeError: (31-37): Data location can only be given for array or struct types.
// TypeError: (31-37): Data location can only be specified for array, struct or mapping types, but "memory" was given.

View File

@ -1,10 +1,8 @@
contract C {
// Warning for no data location provided can be silenced with storage or memory.
function f(uint[] memory, uint[] storage) private pure {}
function g(uint[] memory, uint[] storage) internal pure {}
function h(uint[] memory) public pure {}
// No warning on external functions, because of default to calldata.
function i(uint[]) external pure {}
// No warning for events.
function i(uint[] calldata) external pure {}
// No data location for events.
event e(uint[]);
}
}

View File

@ -1,7 +1,6 @@
contract C {
// Shows that the warning for no data location provided can be silenced with storage or memory.
function f() private pure returns(uint[] memory, uint[] storage b) { b = b; }
function g() internal pure returns(uint[] memory, uint[] storage b) { b = b; }
function h() public pure returns(uint[] memory) {}
function i() external pure returns(uint[] memory) {}
}
}

View File

@ -1,10 +1,8 @@
contract C {
struct Nested { uint y; }
// ensure that we consider array of function pointers as reference type
function a(function(Nested) external returns (uint)[]) public pure {}
function b(function(Nested) external returns (uint)[] storage) public pure {}
function c(function(Nested) external returns (uint)[] memory) public pure {}
function d(function(Nested) external returns (uint)[] calldata) public pure {}
function b(function(Nested memory) external returns (uint)[] storage) internal pure {}
function c(function(Nested memory) external returns (uint)[] memory) public pure {}
function d(function(Nested memory) external returns (uint)[] calldata) external pure {}
}
// ----
// TypeError: (208-250): Location has to be memory for public function. Remove the data location keyword to fix this error.

View File

@ -2,4 +2,4 @@ contract test {
function f(bytes calldata) internal;
}
// ----
// TypeError: (31-36): Variable cannot be declared as "calldata" (remove the "calldata" keyword).
// TypeError: (31-36): Data location must be "storage" or "memory" for parameter in function, but "calldata" was given.

View File

@ -2,4 +2,4 @@ contract C {
function g(uint[]) internal pure {}
}
// ----
// TypeError: (28-34): Storage location must be "storage" or "memory" for parameter in internal function, but none was given.
// TypeError: (28-34): Data location must be "storage" or "memory" for parameter in function, but none was given.

View File

@ -2,4 +2,4 @@ contract C {
function g() internal pure returns(uint[]) {}
}
// ----
// TypeError: (52-58): Storage location must be "storage" or "memory" for parameter in internal function, but none was given.
// TypeError: (52-58): Data location must be "storage" or "memory" for return parameter in function, but none was given.

View File

@ -0,0 +1,12 @@
library L {
struct S { uint x; }
function g(uint[2]) external pure {}
function h(uint[]) external pure {}
function i(S) external pure {}
function j(mapping(uint => uint)) external pure {}
}
// ----
// TypeError: (52-59): Data location must be "storage" or "calldata" for parameter in external function, but none was given.
// TypeError: (93-99): Data location must be "storage" or "calldata" for parameter in external function, but none was given.
// TypeError: (133-134): Data location must be "storage" or "calldata" for parameter in external function, but none was given.
// TypeError: (168-189): Data location must be "storage" or "calldata" for parameter in external function, but none was given.

View File

@ -0,0 +1,12 @@
library L {
struct S { uint x; }
function g() external pure returns (uint[2]) {}
function h() external pure returns (uint[]) {}
function i() external pure returns (S) {}
function j() external pure returns (mapping(uint => uint)) {}
}
// ----
// TypeError: (77-84): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (129-135): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (180-181): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (226-247): Data location must be "storage" or "memory" for return parameter in function, but none was given.

View File

@ -1,8 +0,0 @@
library L {
// Warning for no data location provided can be silenced with storage or memory.
function f(uint[] memory, uint[] storage) private pure {}
function g(uint[] memory, uint[] storage) internal pure {}
function h(uint[] memory) public pure {}
// No warning on external functions, because of default to calldata.
function i(uint[]) external pure {}
}

View File

@ -0,0 +1,10 @@
library L {
struct S { uint x; }
function f(uint[] memory, uint[] storage, S storage) private pure
returns (mapping(uint => uint) storage a, S memory b, uint[] storage c) { return (a, b, c); }
function g(uint[] memory, uint[] storage) internal pure
returns (mapping(uint => uint) storage a, S memory b, uint[] storage c) { return (a, b, c); }
function h(uint[] memory, uint[] storage) public pure returns (S storage x) { return x; }
function i(uint[] calldata, uint[] storage) external pure returns (S storage x) {return x; }
}
// ----

View File

@ -0,0 +1,20 @@
library L {
struct S { uint x; }
function g() internal pure returns (uint[2]) {}
function h() internal pure returns (uint[]) {}
function i() internal pure returns (S) {}
function j() internal pure returns (mapping(uint => uint)) {}
function gp(uint[2]) internal pure {}
function hp(uint[]) internal pure {}
function ip(S) internal pure {}
function jp(mapping(uint => uint)) internal pure {}
}
// ----
// TypeError: (77-84): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (129-135): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (180-181): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (226-247): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (268-275): Data location must be "storage" or "memory" for parameter in function, but none was given.
// TypeError: (310-316): Data location must be "storage" or "memory" for parameter in function, but none was given.
// TypeError: (351-352): Data location must be "storage" or "memory" for parameter in function, but none was given.
// TypeError: (387-408): Data location must be "storage" or "memory" for parameter in function, but none was given.

View File

@ -1,5 +0,0 @@
library L {
function g(uint[]) internal pure {}
}
// ----
// TypeError: (27-33): Storage location must be "storage" or "memory" for parameter in internal function, but none was given.

View File

@ -0,0 +1,20 @@
library L {
struct S { uint x; }
function g() private pure returns (uint[2]) {}
function h() private pure returns (uint[]) {}
function i() private pure returns (S) {}
function j() private pure returns (mapping(uint => uint)) {}
function gp(uint[2]) private pure {}
function hp(uint[]) private pure {}
function ip(S) private pure {}
function jp(mapping(uint => uint)) private pure {}
}
// ----
// TypeError: (76-83): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (127-133): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (177-178): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (222-243): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (264-271): Data location must be "storage" or "memory" for parameter in function, but none was given.
// TypeError: (305-311): Data location must be "storage" or "memory" for parameter in function, but none was given.
// TypeError: (345-346): Data location must be "storage" or "memory" for parameter in function, but none was given.
// TypeError: (380-401): Data location must be "storage" or "memory" for parameter in function, but none was given.

View File

@ -1,5 +0,0 @@
library L {
function h(uint[]) public pure {}
}
// ----
// TypeError: (27-33): Storage location must be "storage" or "memory" for parameter in public function, but none was given.

View File

@ -0,0 +1,19 @@
library L {
struct S { uint x; }
function g() private pure returns (uint[2]) {}
function h() private pure returns (uint[]) {}
function i() private pure returns (S) {}
function j() private pure returns (mapping(uint => uint)) {}
function gp(uint[2]) private pure {}
function hp(uint[]) private pure {}
function ip(S) private pure {}
function jp(mapping(uint => uint)) private pure {}}
// ----
// TypeError: (76-83): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (127-133): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (177-178): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (222-243): Data location must be "storage" or "memory" for return parameter in function, but none was given.
// TypeError: (264-271): Data location must be "storage" or "memory" for parameter in function, but none was given.
// TypeError: (305-311): Data location must be "storage" or "memory" for parameter in function, but none was given.
// TypeError: (345-346): Data location must be "storage" or "memory" for parameter in function, but none was given.
// TypeError: (380-401): Data location must be "storage" or "memory" for parameter in function, but none was given.

View File

@ -1,5 +0,0 @@
library L {
function h(uint[]) public pure {}
}
// ----
// TypeError: (27-33): Storage location must be "storage" or "memory" for parameter in public function, but none was given.

View File

@ -2,4 +2,4 @@ library test {
function f(bytes memory) external;
}
// ----
// TypeError: (30-35): Location has to be calldata or storage for external library functions (remove the "memory" keyword).
// TypeError: (30-35): Data location must be "storage" or "calldata" for parameter in external function, but "memory" was given.

View File

@ -2,4 +2,4 @@ library test {
function f(bytes calldata) internal pure {}
}
// ----
// TypeError: (30-35): Variable cannot be declared as "calldata" (remove the "calldata" keyword).
// TypeError: (30-35): Data location must be "storage" or "memory" for parameter in function, but "calldata" was given.

View File

@ -2,4 +2,4 @@ contract C {
function f(uint[]) private pure {}
}
// ----
// TypeError: (28-34): Storage location must be "storage" or "memory" for parameter in private function, but none was given.
// TypeError: (28-34): Data location must be "storage" or "memory" for parameter in function, but none was given.

View File

@ -2,4 +2,4 @@ contract C {
function f() private pure returns(uint[]) {}
}
// ----
// TypeError: (51-57): Storage location must be "storage" or "memory" for parameter in private function, but none was given.
// TypeError: (51-57): Data location must be "storage" or "memory" for return parameter in function, but none was given.

View File

@ -2,4 +2,4 @@ contract test {
function f(bytes calldata) public;
}
// ----
// TypeError: (31-36): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
// TypeError: (31-36): Data location must be "memory" for parameter in function, but "calldata" was given.

View File

@ -2,4 +2,4 @@ contract test {
function f(bytes storage) public;
}
// ----
// TypeError: (31-36): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
// TypeError: (31-36): Data location must be "memory" for parameter in function, but "storage" was given.

View File

@ -2,4 +2,4 @@ contract C {
function h(uint[]) public pure {}
}
// ----
// TypeError: (28-34): Storage location must be "memory" for parameter in public function, but none was given.
// TypeError: (28-34): Data location must be "memory" for parameter in function, but none was given.

View File

@ -2,4 +2,4 @@ contract C {
function h() public pure returns(uint[]) {}
}
// ----
// TypeError: (50-56): Storage location must be "memory" for parameter in public function, but none was given.
// TypeError: (50-56): Data location must be "memory" for return parameter in function, but none was given.

View File

@ -7,7 +7,7 @@ contract test {
}
}
// ----
// TypeError: (48-63): Data location can only be given for array or struct types.
// TypeError: (71-89): Data location can only be given for array or struct types.
// TypeError: (97-111): Data location can only be given for array or struct types.
// TypeError: (119-136): Data location can only be given for array or struct types.
// TypeError: (48-63): Data location can only be specified for array, struct or mapping types, but "storage" was given.
// TypeError: (71-89): Data location can only be specified for array, struct or mapping types, but "storage" was given.
// TypeError: (97-111): Data location can only be specified for array, struct or mapping types, but "memory" was given.
// TypeError: (119-136): Data location can only be specified for array, struct or mapping types, but "memory" was given.

View File

@ -3,7 +3,7 @@
// when converting to a function type.
contract C {
function f(function(bytes memory) pure external /*g*/) pure public { }
function callback(bytes) pure external {}
function callback(bytes calldata) pure external {}
function g() view public {
f(this.callback);
}

View File

@ -2,6 +2,6 @@ contract test {
function f(uint[] memory constant a) public { }
}
// ----
// TypeError: (31-55): Illegal use of "constant" specifier.
// DeclarationError: (31-55): The "constant" keyword can only be used for state variables.
// TypeError: (31-55): Constants of non-value type not yet implemented.
// TypeError: (31-55): Uninitialized "constant" variable.

View File

@ -1,8 +1,8 @@
contract Vehicle {
function f(bytes) external returns (uint256 r) {r = 1;}
function f(bytes calldata) external returns (uint256 r) {r = 1;}
}
contract Bike is Vehicle {
function f(bytes) external returns (uint256 r) {r = 42;}
function f(bytes calldata) external returns (uint256 r) {r = 42;}
}
// ----
// Warning: (23-78): Function state mutability can be restricted to pure
// Warning: (23-87): Function state mutability can be restricted to pure

View File

@ -2,4 +2,4 @@ contract C {
function f(uint[] memory a) external {}
}
// ----
// TypeError: (28-43): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
// TypeError: (28-43): Data location must be "calldata" for parameter in external function, but "memory" was given.

View File

@ -2,4 +2,4 @@ contract C {
function f(uint[] storage a) external {}
}
// ----
// TypeError: (28-44): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
// TypeError: (28-44): Data location must be "calldata" for parameter in external function, but "storage" was given.

View File

@ -1,17 +1,11 @@
contract Test {
string s;
bytes b;
function h(string _s) external { bytes(_s).length; }
function i(string memory _s) internal { bytes(_s).length; }
function j() internal { bytes(s).length; }
function k(bytes _b) external { string(_b); }
function l(bytes memory _b) internal { string(_b); }
function m() internal { string(b); }
function h(string calldata _s) pure external { bytes(_s).length; }
function i(string memory _s) pure internal { bytes(_s).length; }
function j() view internal { bytes(s).length; }
function k(bytes calldata _b) pure external { string(_b); }
function l(bytes memory _b) pure internal { string(_b); }
function m() view internal { string(b); }
}
// ----
// Warning: (47-99): Function state mutability can be restricted to pure
// Warning: (104-163): Function state mutability can be restricted to pure
// Warning: (168-210): Function state mutability can be restricted to view
// Warning: (215-260): Function state mutability can be restricted to pure
// Warning: (265-317): Function state mutability can be restricted to pure
// Warning: (322-358): Function state mutability can be restricted to view

View File

@ -1,9 +1,9 @@
contract C {
function f(bytes bytesAsCalldata) external {
function f(bytes calldata bytesAsCalldata) external {
assembly {
let x := bytesAsCalldata
}
}
}
// ----
// TypeError: (102-117): Call data elements cannot be accessed directly. Copy to a local variable first or use "calldataload" or "calldatacopy" with manually determined offsets and sizes.
// TypeError: (111-126): Call data elements cannot be accessed directly. Copy to a local variable first or use "calldataload" or "calldatacopy" with manually determined offsets and sizes.

View File

@ -9,5 +9,5 @@ contract C {
}
}
// ----
// TypeError: (104-107): Data location must be specified as either "memory" or "storage".
// TypeError: (123-131): Data location must be specified as either "memory" or "storage".
// TypeError: (104-107): Data location must be "storage" or "memory" for variable, but none was given.
// TypeError: (123-131): Data location must be "storage" or "memory" for variable, but none was given.

View File

@ -2,4 +2,4 @@ contract C {
function f(uint storage a) public { }
}
// ----
// TypeError: (28-42): Data location can only be given for array or struct types.
// TypeError: (28-42): Data location can only be specified for array, struct or mapping types, but "storage" was given.

View File

@ -4,4 +4,4 @@ contract C {
}
}
// ----
// TypeError: (28-42): Data location can only be given for array or struct types.
// TypeError: (28-42): Data location can only be specified for array, struct or mapping types, but "storage" was given.

View File

@ -1,6 +1,6 @@
contract C {
function f(uint[85678901234] a) pure external {
function f(uint[85678901234] calldata a) pure external {
}
}
// ----
// TypeError: (28-47): Array is too large to be encoded.
// TypeError: (28-56): Array is too large to be encoded.

View File

@ -2,4 +2,6 @@ contract Foo {
function f(uint[] storage constant x, uint[] memory y) internal { }
}
// ----
// TypeError: (30-55): Data location has to be "memory" (or unspecified) for constants.
// DeclarationError: (30-55): The "constant" keyword can only be used for state variables.
// TypeError: (30-55): Constants of non-value type not yet implemented.
// TypeError: (30-55): Uninitialized "constant" variable.

View File

@ -3,5 +3,4 @@ contract C {
}
}
// ----
// TypeError: (28-49): Type is required to live outside storage.
// TypeError: (28-49): Internal or recursive type is not allowed for public or external functions.
// TypeError: (28-49): Data location must be "calldata" for parameter in external function, but "storage" was given.

View File

@ -3,5 +3,4 @@ contract C {
}
}
// ----
// TypeError: (28-49): Type is required to live outside storage.
// TypeError: (28-49): Internal or recursive type is not allowed for public or external functions.
// TypeError: (28-49): Data location must be "memory" for parameter in function, but "storage" was given.

View File

@ -3,4 +3,4 @@ contract C {
}
}
// ----
// TypeError: (28-51): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
// TypeError: (28-51): Data location must be "calldata" for parameter in external function, but "storage" was given.

View File

@ -3,4 +3,4 @@ contract C {
}
}
// ----
// TypeError: (28-51): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
// TypeError: (28-51): Data location must be "memory" for parameter in function, but "storage" was given.

View File

@ -3,4 +3,5 @@ contract C {
}
}
// ----
// TypeError: (37-56): Data location must be "memory" for parameter in function, but "storage" was given.
// TypeError: (37-56): Internal type cannot be used for external function type.

View File

@ -3,4 +3,5 @@ contract C {
}
}
// ----
// TypeError: (57-76): Data location must be "memory" for return parameter in function, but "storage" was given.
// TypeError: (57-76): Internal type cannot be used for external function type.

View File

@ -3,4 +3,4 @@ contract C {
}
}
// ----
// TypeError: (53-84): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
// TypeError: (53-84): Data location must be "memory" for return parameter in function, but "storage" was given.

View File

@ -3,4 +3,4 @@ contract C {
}
}
// ----
// TypeError: (51-82): Location has to be memory for publicly visible functions (remove the "storage" or "calldata" keyword).
// TypeError: (51-82): Data location must be "memory" for return parameter in function, but "storage" was given.

View File

@ -6,4 +6,4 @@ contract c {
}
}
// ----
// TypeError: (81-113): Data location for mappings must be specified as "storage".
// TypeError: (81-113): Data location must be "storage" for variable, but "calldata" was given.

View File

@ -6,4 +6,4 @@ contract c {
}
}
// ----
// TypeError: (81-104): Data location for mappings must be specified as "storage".
// TypeError: (81-104): Data location must be "storage" for variable, but none was given.

View File

@ -6,4 +6,4 @@ contract c {
}
}
// ----
// TypeError: (81-111): Data location for mappings must be specified as "storage".
// TypeError: (81-111): Data location must be "storage" for variable, but "memory" was given.

View File

@ -3,5 +3,4 @@ contract C {
}
}
// ----
// TypeError: (53-82): Type is required to live outside storage.
// TypeError: (53-82): Internal or recursive type is not allowed for public or external functions.
// TypeError: (53-82): Data location must be "memory" for return parameter in function, but "storage" was given.

View File

@ -3,5 +3,4 @@ contract C {
}
}
// ----
// TypeError: (51-80): Type is required to live outside storage.
// TypeError: (51-80): Internal or recursive type is not allowed for public or external functions.
// TypeError: (51-80): Data location must be "memory" for return parameter in function, but "storage" was given.

View File

@ -0,0 +1,7 @@
contract C {
function f() public pure returns (mapping(uint=>uint) memory m) {
}
}
// ----
// TypeError: (51-79): Type is required to live outside storage.
// TypeError: (51-79): Internal or recursive type is not allowed for public or external functions.