aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/syntaxTests
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-07-24 03:43:38 +0800
committerGitHub <noreply@github.com>2018-07-24 03:43:38 +0800
commitde90290c2882a580ab5e9cc222bd4caa21ac7667 (patch)
tree0748cef73a8bee2c1c51710bd05303425543a50f /test/libsolidity/syntaxTests
parentb3c8e14952f86ab658ac456f5cce71609498a348 (diff)
parentc622a1e56c0a02b890b45fd15f1fb4cb9d119b3b (diff)
downloaddexon-solidity-de90290c2882a580ab5e9cc222bd4caa21ac7667.tar.gz
dexon-solidity-de90290c2882a580ab5e9cc222bd4caa21ac7667.tar.zst
dexon-solidity-de90290c2882a580ab5e9cc222bd4caa21ac7667.zip
Merge pull request #4527 from ethereum/mappingEnforceStorage
Enforces explicit data location for mappings
Diffstat (limited to 'test/libsolidity/syntaxTests')
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/210_uninitialized_mapping_variable.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol2
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/mapping_data_location_calldata.sol9
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/mapping_data_location_default.sol9
-rw-r--r--test/libsolidity/syntaxTests/types/mapping/mapping_data_location_memory.sol9
8 files changed, 36 insertions, 9 deletions
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol
index 8bf45c3f..27b1ea96 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol
@@ -4,9 +4,9 @@ contract test {
}
str data;
function fun() public {
- mapping(uint=>uint) a = data.map;
+ mapping(uint=>uint) storage a = data.map;
data.map = a;
}
}
// ----
-// TypeError: (164-176): Mappings cannot be assigned to.
+// TypeError: (172-184): Mappings cannot be assigned to.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol
index 27651d63..b15666c0 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/025_comparison_of_mapping_types.sol
@@ -1,9 +1,9 @@
contract C {
mapping(uint => uint) x;
function f() public returns (bool ret) {
- mapping(uint => uint) y = x;
+ mapping(uint => uint) storage y = x;
return x == y;
}
}
// ----
-// TypeError: (139-145): Operator == not compatible with types mapping(uint256 => uint256) and mapping(uint256 => uint256)
+// TypeError: (147-153): Operator == not compatible with types mapping(uint256 => uint256) and mapping(uint256 => uint256)
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/210_uninitialized_mapping_variable.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/210_uninitialized_mapping_variable.sol
index 6b25cdfe..0547ace1 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/210_uninitialized_mapping_variable.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/210_uninitialized_mapping_variable.sol
@@ -1,8 +1,8 @@
contract C {
function f() public {
- mapping(uint => uint) x;
+ mapping(uint => uint) storage x;
x;
}
}
// ----
-// TypeError: (47-70): Uninitialized mapping. Mappings cannot be created dynamically, you have to assign them from a state variable.
+// TypeError: (47-78): Uninitialized mapping. Mappings cannot be created dynamically, you have to assign them from a state variable.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol
index f0bb557b..e45e09de 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/264_mapping_in_memory_array.sol
@@ -1,7 +1,7 @@
contract C {
function f(uint size) public {
- mapping(uint => uint) x = new mapping(uint => uint)[](4);
+ mapping(uint => uint) storage x = new mapping(uint => uint)[](4);
}
}
// ----
-// TypeError: (86-109): Type cannot live outside storage.
+// TypeError: (94-117): Type cannot live outside storage.
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol
index 41e72d60..e9ab08ba 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/288_conditional_with_all_types.sol
@@ -71,7 +71,7 @@ contract C {
(uint n, uint o) = true ? (1, 2) : (3, 4);
(n, o) = (o, n); // Avoid unused var warning
// mapping
- mapping(uint8 => uint8) p = true ? table1 : table2;
+ mapping(uint8 => uint8) storage p = true ? table1 : table2;
p[0] = 0; // Avoid unused var warning
// typetype
uint32 q = true ? uint32(1) : uint32(2);
diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_calldata.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_calldata.sol
new file mode 100644
index 00000000..c73c7f32
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_calldata.sol
@@ -0,0 +1,9 @@
+contract c {
+ mapping(uint => uint) y;
+ function f() view public {
+ mapping(uint => uint) calldata x = y;
+ x;
+ }
+}
+// ----
+// TypeError: (81-113): Data location for mappings must be specified as "storage".
diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_default.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_default.sol
new file mode 100644
index 00000000..85531ae1
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_default.sol
@@ -0,0 +1,9 @@
+contract c {
+ mapping(uint => uint) y;
+ function f() view public {
+ mapping(uint => uint) x = y;
+ x;
+ }
+}
+// ----
+// TypeError: (81-104): Data location for mappings must be specified as "storage".
diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_memory.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_memory.sol
new file mode 100644
index 00000000..7151e887
--- /dev/null
+++ b/test/libsolidity/syntaxTests/types/mapping/mapping_data_location_memory.sol
@@ -0,0 +1,9 @@
+contract c {
+ mapping(uint => uint) y;
+ function f() view public {
+ mapping(uint => uint) memory x = y;
+ x;
+ }
+}
+// ----
+// TypeError: (81-111): Data location for mappings must be specified as "storage".