Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
PaulRBerg opened this issue Feb 4, 2023 · 7 comments
Closed

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

PaulRBerg opened this issue Feb 4, 2023 · 7 comments

Comments

@PaulRBerg
Copy link
Contributor

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
Copy link
Contributor

fvictorio commented Feb 5, 2023

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
Copy link
Contributor Author

PaulRBerg commented Feb 5, 2023

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

@andreivladbrg
Copy link

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

@gitpusha
Copy link

Would be great to get support for this!

@cyberhorsey
Copy link

Also would love this : )

@dbale-altoros
Copy link
Collaborator

Guys, I created a new rule for this in this PR
#403

@PaulRBerg
Copy link
Contributor Author

PaulRBerg commented Feb 17, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants