mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
New test cases.
This commit is contained in:
parent
b000a022f2
commit
16de7a0493
@ -0,0 +1,11 @@
|
||||
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.
|
@ -0,0 +1,5 @@
|
||||
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.
|
@ -0,0 +1,10 @@
|
||||
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.
|
||||
event e(uint[]);
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
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) {}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
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 {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (208-250): Location has to be memory for public function. Remove the data location keyword to fix this error.
|
@ -0,0 +1,5 @@
|
||||
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.
|
@ -0,0 +1,5 @@
|
||||
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.
|
@ -0,0 +1,8 @@
|
||||
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 {}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
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.
|
@ -0,0 +1,5 @@
|
||||
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.
|
@ -0,0 +1,5 @@
|
||||
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.
|
@ -0,0 +1,5 @@
|
||||
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.
|
@ -0,0 +1,5 @@
|
||||
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.
|
@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
function h(uint[]) public pure {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (28-34): Storage location must be "memory" for parameter in public function, but none was given.
|
@ -0,0 +1,5 @@
|
||||
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.
|
@ -0,0 +1,8 @@
|
||||
contract C {
|
||||
// This should probably have a better error message at some point.
|
||||
// Constant mappings should not be possible in general.
|
||||
mapping(uint => uint) constant x;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (148-180): Constants of non-value type not yet implemented.
|
||||
// TypeError: (148-180): Uninitialized "constant" variable.
|
@ -0,0 +1,6 @@
|
||||
contract c {
|
||||
function f1(mapping(uint => uint)[] calldata) pure external {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (29-52): Type is required to live outside storage.
|
||||
// TypeError: (29-52): Internal or recursive type is not allowed for public or external functions.
|
@ -0,0 +1,6 @@
|
||||
contract c {
|
||||
function f1(mapping(uint => uint) calldata) pure external returns (mapping(uint => uint) memory) {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (29-50): Type is required to live outside storage.
|
||||
// TypeError: (29-50): Internal or recursive type is not allowed for public or external functions.
|
@ -0,0 +1,4 @@
|
||||
contract c {
|
||||
function f4(mapping(uint => uint) memory) pure internal {}
|
||||
}
|
||||
// ----
|
@ -0,0 +1,6 @@
|
||||
contract c {
|
||||
function f3(mapping(uint => uint) memory) view public {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (29-50): Type is required to live outside storage.
|
||||
// TypeError: (29-50): Internal or recursive type is not allowed for public or external functions.
|
Loading…
Reference in New Issue
Block a user