mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allow using calldata keyword to specify data location
This commit is contained in:
+4
@@ -0,0 +1,4 @@
|
||||
contract test {
|
||||
function f(bytes calldata) external;
|
||||
}
|
||||
// ----
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
function f(bytes memory) external;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (31-36): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
function f(bytes storage) external;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (31-36): Location has to be calldata for external functions (remove the "memory" or "storage" keyword).
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
library test {
|
||||
function f(bytes calldata) public;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (30-35): Location cannot be calldata for non-external functions (remove the "calldata" keyword).
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
function f(bytes4 memory) public;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (31-37): Data location can only be given for array or struct types.
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
function f(bytes calldata) internal;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (31-36): Variable cannot be declared as "calldata" (remove the "calldata" keyword).
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
contract test {
|
||||
function f(bytes memory) internal;
|
||||
}
|
||||
// ----
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
contract test {
|
||||
function f(bytes storage) internal;
|
||||
}
|
||||
// ----
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
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).
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
contract test {
|
||||
function f(bytes memory) public;
|
||||
}
|
||||
// ----
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
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).
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
contract test {
|
||||
function f() {
|
||||
uint storage a1;
|
||||
bytes16 storage b1;
|
||||
uint memory a2;
|
||||
bytes16 memory b2;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (41-56): Data location can only be given for array or struct types.
|
||||
// TypeError: (64-82): Data location can only be given for array or struct types.
|
||||
// TypeError: (90-104): Data location can only be given for array or struct types.
|
||||
// TypeError: (112-129): Data location can only be given for array or struct types.
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
contract test {
|
||||
uint[] a;
|
||||
uint[] b;
|
||||
function f() public {
|
||||
uint[] storage s1 = a;
|
||||
uint[] memory s2 = new uint[](42);
|
||||
uint[] s3 = b;
|
||||
s1.push(42);
|
||||
s2[3] = 12;
|
||||
s3.push(42);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (147-156): Variable is declared as a storage pointer. Use an explicit "storage" keyword to silence this warning.
|
||||
@@ -2,4 +2,4 @@ contract Foo {
|
||||
function f(uint[] storage constant x, uint[] memory y) internal { }
|
||||
}
|
||||
// ----
|
||||
// TypeError: (30-55): Storage location has to be "memory" (or unspecified) for constants.
|
||||
// TypeError: (30-55): Data location has to be "memory" (or unspecified) for constants.
|
||||
|
||||
Reference in New Issue
Block a user