Disallow assignments to mappings within tuple assignments.

This commit is contained in:
Daniel Kirchner
2018-08-03 15:46:26 +02:00
parent da6cefd475
commit c0a169ca90
7 changed files with 70 additions and 17 deletions
@@ -1,12 +0,0 @@
contract test {
struct str {
mapping(uint=>uint) map;
}
str data;
function fun() public {
mapping(uint=>uint) storage a = data.map;
data.map = a;
}
}
// ----
// TypeError: (172-184): Mappings cannot be assigned to.
@@ -0,0 +1,15 @@
contract test {
mapping(uint=>uint) map;
function fun() public view {
mapping(uint=>uint) storage a = map;
mapping(uint=>uint) storage b = map;
b = a;
(b) = a;
(b, b) = (a, a);
}
}
// ----
// TypeError: (176-177): Mappings cannot be assigned to.
// TypeError: (192-193): Mappings cannot be assigned to.
// TypeError: (209-210): Mappings cannot be assigned to.
// TypeError: (212-213): Mappings cannot be assigned to.
@@ -0,0 +1,14 @@
contract test {
mapping(uint=>uint) map;
function fun() public {
mapping(uint=>uint) storage a = map;
map = a;
(map) = a;
(map, map) = (a, a);
}
}
// ----
// TypeError: (126-129): Mappings cannot be assigned to.
// TypeError: (144-147): Mappings cannot be assigned to.
// TypeError: (163-166): Mappings cannot be assigned to.
// TypeError: (168-171): Mappings cannot be assigned to.
@@ -0,0 +1,17 @@
contract test {
struct str {
mapping(uint=>uint) map;
}
str data;
function fun() public {
mapping(uint=>uint) storage a = data.map;
data.map = a;
(data.map) = a;
(data.map, data.map) = (a, a);
}
}
// ----
// TypeError: (172-180): Mappings cannot be assigned to.
// TypeError: (195-203): Mappings cannot be assigned to.
// TypeError: (219-227): Mappings cannot be assigned to.
// TypeError: (229-237): Mappings cannot be assigned to.