protofire / solhint

Solhint is an open-source project to provide a linting utility for Solidity code.
https://protofire.github.io/solhint/
MIT License
1.04k stars 160 forks source link

Support for named parameters in mappings (Solidity v0.8.18) #397

Closed PaulRBerg closed 1 year ago

PaulRBerg commented 1 year ago

Solidity v0.8.18 was released earlier this week, and one of the newly introduced features are named parameters in mappings. That means that we can now define mappings like this:

contract Foo {
    mapping(address key => uint256 value) public items;
    mapping(string name => uint256 balance) public users;
}

Solhint throws with the following error when it sees the code above:

Linter: Parse error: extraneous input 'key' expecting '=>' [undefined]

fvictorio commented 1 year ago

Two things to do here:

1) Update the parser (I already added support for named mapping parameters in it) 2) Open an issue about adding a new rule that suggests using named parameters. This rule will only make sense for solidity >=0.8.18, so it should be disabled by default, and not included in the recommended preset config.

PaulRBerg commented 1 year ago

Agree, a rule would be cool. But I think until the rule gets added, just adding support for the parsing would be helpful.

andreivladbrg commented 1 year ago

Hey @fvictorio, do you have any updates on this? My github actions are failing because of this.

gitpusha commented 1 year ago

Would be great to get support for this!

cyberhorsey commented 1 year ago

Also would love this : )

dbale-altoros commented 1 year ago

Guys, I created a new rule for this in this PR https://github.com/protofire/solhint/pull/403

PaulRBerg commented 1 year ago

Looks like this issue can be closed now, since v3.4.0 includes support for named mapping params 🥳

https://github.com/protofire/solhint/blob/37d9b14883c4aac29fde19e4b0bf15996bda6953/CHANGELOG.md