Allow assignments to local variables of mapping types.

This commit is contained in:
Daniel Kirchner
2018-08-03 16:22:03 +02:00
parent c0a169ca90
commit 1e4b5886d6
7 changed files with 67 additions and 5 deletions
@@ -9,7 +9,3 @@ contract test {
}
}
// ----
// 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,7 @@
contract C {
function f() external pure returns (mapping(uint=>uint) storage m) {
}
}
// ----
// TypeError: (53-82): Type is required to live outside storage.
// TypeError: (53-82): Internal or recursive type is not allowed for public or external functions.
@@ -0,0 +1,21 @@
// This should be allowed in a future release.
contract C {
mapping(uint=>uint) m;
function f() internal view returns (mapping(uint=>uint) storage) {
return m;
}
function g() private view returns (mapping(uint=>uint) storage) {
return m;
}
function h() internal view returns (mapping(uint=>uint) storage r) {
r = m;
}
function i() private view returns (mapping(uint=>uint) storage r) {
(r,r) = (m,m);
}
}
// ----
// TypeError: (127-146): Type is required to live outside storage.
// TypeError: (221-240): Type is required to live outside storage.
// TypeError: (316-345): Type is required to live outside storage.
// TypeError: (409-438): Type is required to live outside storage.
@@ -0,0 +1,7 @@
contract C {
function f() public pure returns (mapping(uint=>uint) storage m) {
}
}
// ----
// TypeError: (51-80): Type is required to live outside storage.
// TypeError: (51-80): Internal or recursive type is not allowed for public or external functions.