diff options
author | Daniel Kirchner <daniel@ekpyron.org> | 2018-08-03 22:22:03 +0800 |
---|---|---|
committer | Daniel Kirchner <daniel@ekpyron.org> | 2018-08-03 22:22:03 +0800 |
commit | 1e4b5886d61328d951fc03dc88cfc3dd722a3a00 (patch) | |
tree | 15196aa2588e31f6d8bf135b9b4a7a7acb6263a7 /test/libsolidity/syntaxTests | |
parent | c0a169ca90b780d102442aca98d1c510dac47464 (diff) | |
download | dexon-solidity-1e4b5886d61328d951fc03dc88cfc3dd722a3a00.tar dexon-solidity-1e4b5886d61328d951fc03dc88cfc3dd722a3a00.tar.gz dexon-solidity-1e4b5886d61328d951fc03dc88cfc3dd722a3a00.tar.bz2 dexon-solidity-1e4b5886d61328d951fc03dc88cfc3dd722a3a00.tar.lz dexon-solidity-1e4b5886d61328d951fc03dc88cfc3dd722a3a00.tar.xz dexon-solidity-1e4b5886d61328d951fc03dc88cfc3dd722a3a00.tar.zst dexon-solidity-1e4b5886d61328d951fc03dc88cfc3dd722a3a00.zip |
Allow assignments to local variables of mapping types.
Diffstat (limited to 'test/libsolidity/syntaxTests')
4 files changed, 35 insertions, 4 deletions
diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol index ba01c44a..a329c91e 100644 --- a/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol @@ -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. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_external.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_external.sol new file mode 100644 index 00000000..85121241 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_external.sol @@ -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. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol new file mode 100644 index 00000000..a46003f8 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_internal.sol @@ -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. diff --git a/test/libsolidity/syntaxTests/types/mapping/mapping_return_public.sol b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public.sol new file mode 100644 index 00000000..383fa797 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/mapping_return_public.sol @@ -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. |