mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow assignments to mappings within tuple assignments.
This commit is contained in:
@@ -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.
|
||||
Reference in New Issue
Block a user