Error when Mapping type in (non-local) storage is assigned to

This commit is contained in:
Harikrishnan Mulackal
2020-05-19 19:12:38 +05:30
parent 142a6b0d4f
commit 774edd4670
5 changed files with 55 additions and 1 deletions
@@ -0,0 +1,10 @@
contract D {
mapping (uint => uint) a;
mapping (uint => uint) b;
function foo() public view {
mapping (uint => uint) storage c = b;
b = c;
}
}
// ----
// TypeError: (160-161): Mappings cannot be assigned to.
@@ -0,0 +1,27 @@
contract C {
mapping (uint => address payable [ ]) public a = a ;
}
contract D {
mapping (uint => uint) a;
mapping (uint => uint) b = a;
}
contract F {
mapping (uint => uint) a;
mapping (uint => uint) b;
function foo() public {
a = b;
}
}
contract G {
uint x = 1;
mapping (uint => uint) b = x;
}
// ----
// TypeError: (17-67): Mappings cannot be assigned to.
// TypeError: (120-148): Mappings cannot be assigned to.
// TypeError: (263-264): Mappings cannot be assigned to.
// TypeError: (312-340): Mappings cannot be assigned to.
@@ -0,0 +1,8 @@
contract D {
mapping (uint => uint) a;
function foo() public view {
mapping (uint => int) storage c = a;
}
}
// ----
// TypeError: (84-119): Type mapping(uint256 => uint256) is not implicitly convertible to expected type mapping(uint256 => int256).