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
@@ -10,4 +10,6 @@ contract Error2 {
mapping (address => uint balances; // missing ) before "balances"
}
// ----
// ParserError 6635: (417-425): Expected ')' but got identifier
// ParserError 6635: (425-426): Expected ')' but got ';'
// ParserError 6635: (425-426): Expected identifier but got ';'
// ParserError 6635: (458-459): Expected ';' but got '}'
@@ -17,7 +17,8 @@ contract SendCoin {
}
// ----
// ParserError 6635: (212-220): Expected ')' but got identifier
// ParserError 6635: (220-221): Expected ';' but got ')'
// ParserError 9182: (220-221): Function, variable, struct or modifier declaration expected.
// Warning 3796: (235-236): Recovered in ContractDefinition at '}'.
// ParserError 6635: (235-236): Expected identifier but got '}'
// ParserError 6635: (276-284): Expected ';' but got 'contract'
// ParserError 9182: (276-284): Function, variable, struct or modifier declaration expected.
// Warning 3796: (572-573): Recovered in ContractDefinition at '}'.
// ParserError 7858: (574-575): Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition.