feat: allow named parameters in mapping types

Co-authored-by: Hari <webmail.hari@gmail.com>

test: add parser and abi test cases

docs: add example on using named parameters for mappings

- Add changelog

feat: update antlr grammar to allow named parameters in mappings

fix: prevent conflicting mapping parameter names

ref: change order of mapping initializers

test: update expectations and fix build

test: add more tests

fix: use common error & code for conflicting params

fix: issue with accessing nested mapping

test: add conflicting params tests for more nested levels

Update libsolidity/analysis/DeclarationTypeChecker.cpp

Co-authored-by: Nikola Matić <nikola.matic@ethereum.org>

fix: error reported with the same code twice

test: add more tests for 3 level nested mapping

Address review comments
This commit is contained in:
Soham Zemse
2022-12-08 11:56:58 +01:00
committed by Nikola Matic
co-authored by Hari Nikola Matić
parent 1c8745c54a
commit fa78e0f3d4
75 changed files with 530 additions and 30 deletions
@@ -48,6 +48,7 @@
"typeName":
{
"id": 3,
"keyName": "",
"keyType":
{
"id": 1,
@@ -67,6 +68,7 @@
"typeIdentifier": "t_mapping$_t_address_$_t_address_payable_$",
"typeString": "mapping(address => address payable)"
},
"valueName": "",
"valueType":
{
"id": 2,
@@ -29,6 +29,7 @@
"typeName":
{
"id": 3,
"keyName": "",
"keyType":
{
"id": 1,
@@ -40,6 +41,7 @@
"nodeType": "Mapping",
"src": "17:35:1",
"typeDescriptions": {},
"valueName": "",
"valueType":
{
"id": 2,
+6
View File
@@ -79,6 +79,7 @@
"typeName":
{
"id": 8,
"keyName": "",
"keyType":
{
"id": 6,
@@ -110,6 +111,7 @@
"typeIdentifier": "t_mapping$_t_contract$_C_$19_$_t_bool_$",
"typeString": "mapping(contract C => bool)"
},
"valueName": "",
"valueType":
{
"id": 7,
@@ -144,6 +146,7 @@
"typeName":
{
"id": 12,
"keyName": "",
"keyType":
{
"id": 10,
@@ -163,6 +166,7 @@
"typeIdentifier": "t_mapping$_t_address_$_t_bool_$",
"typeString": "mapping(address => bool)"
},
"valueName": "",
"valueType":
{
"id": 11,
@@ -197,6 +201,7 @@
"typeName":
{
"id": 17,
"keyName": "",
"keyType":
{
"id": 15,
@@ -228,6 +233,7 @@
"typeIdentifier": "t_mapping$_t_enum$_E_$4_$_t_bool_$",
"typeString": "mapping(enum C.E => bool)"
},
"valueName": "",
"valueType":
{
"id": 16,
@@ -60,6 +60,7 @@
"typeName":
{
"id": 8,
"keyName": "",
"keyType":
{
"id": 6,
@@ -81,6 +82,7 @@
"nodeType": "Mapping",
"src": "40:18:1",
"typeDescriptions": {},
"valueName": "",
"valueType":
{
"id": 7,
@@ -106,6 +108,7 @@
"typeName":
{
"id": 12,
"keyName": "",
"keyType":
{
"id": 10,
@@ -117,6 +120,7 @@
"nodeType": "Mapping",
"src": "66:24:1",
"typeDescriptions": {},
"valueName": "",
"valueType":
{
"id": 11,
@@ -142,6 +146,7 @@
"typeName":
{
"id": 17,
"keyName": "",
"keyType":
{
"id": 15,
@@ -163,6 +168,7 @@
"nodeType": "Mapping",
"src": "98:18:1",
"typeDescriptions": {},
"valueName": "",
"valueType":
{
"id": 16,
@@ -287,6 +287,7 @@
"typeName":
{
"id": 25,
"keyName": "",
"keyType":
{
"id": 22,
@@ -318,6 +319,7 @@
"typeIdentifier": "t_mapping$_t_userDefinedValueType$_MyAddress_$18_$_t_userDefinedValueType$_MyUInt_$20_$",
"typeString": "mapping(C.MyAddress => C.MyUInt)"
},
"valueName": "",
"valueType":
{
"id": 24,
@@ -213,6 +213,7 @@
"typeName":
{
"id": 25,
"keyName": "",
"keyType":
{
"id": 22,
@@ -234,6 +235,7 @@
"nodeType": "Mapping",
"src": "169:28:1",
"typeDescriptions": {},
"valueName": "",
"valueType":
{
"id": 24,