diff options
author | Daniel Kirchner <daniel@ekpyron.org> | 2018-08-03 20:32:37 +0800 |
---|---|---|
committer | Daniel Kirchner <daniel@ekpyron.org> | 2018-08-03 21:46:26 +0800 |
commit | c0a169ca90b780d102442aca98d1c510dac47464 (patch) | |
tree | 409d04e77d426d57dd2a53167a962b35abe2fd62 /test/libsolidity | |
parent | da6cefd475210a9bcae0aad80c03f3679ae00f56 (diff) | |
download | dexon-solidity-c0a169ca90b780d102442aca98d1c510dac47464.tar dexon-solidity-c0a169ca90b780d102442aca98d1c510dac47464.tar.gz dexon-solidity-c0a169ca90b780d102442aca98d1c510dac47464.tar.bz2 dexon-solidity-c0a169ca90b780d102442aca98d1c510dac47464.tar.lz dexon-solidity-c0a169ca90b780d102442aca98d1c510dac47464.tar.xz dexon-solidity-c0a169ca90b780d102442aca98d1c510dac47464.tar.zst dexon-solidity-c0a169ca90b780d102442aca98d1c510dac47464.zip |
Disallow assignments to mappings within tuple assignments.
Diffstat (limited to 'test/libsolidity')
4 files changed, 46 insertions, 12 deletions
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol deleted file mode 100644 index 27b1ea96..00000000 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/016_assignment_to_mapping.sol +++ /dev/null @@ -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. diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol new file mode 100644 index 00000000..ba01c44a --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_local.sol @@ -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. diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol new file mode 100644 index 00000000..1323afe6 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_state_variable.sol @@ -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. diff --git a/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol b/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol new file mode 100644 index 00000000..b89241ed --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/assignment_struct.sol @@ -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. |