Fix/solc 0.7.4 warnings #2391#2396
Conversation
|
Thank you @zemse! I'm not very fond of the underscore suffix. I know we use it in a few places, but so far it has only been when the underscore prefix was not available due to shadowing. Rather than adopting this convention for all arguments, I would prefer to continue with our current convention:
There may be some issues with this approach but I would rather we solved the warnings as simply as possible first, then discuss the issues with this convention and if necessary come up with a new one. Would you like to make the changes I suggested? |
|
I get the point. This is something which I could discuss before actually making the change.
Yeah, likely by EOD. |
This commit fixes warnings thrown by the solc 0.7.4 compiler: "Warning: Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable."
This commit fixes warnings thrown by the solc 0.7.4 compiler: "Warning: Function state mutability can be restricted to pure"
a28d37e to
909216a
Compare
This commit fixes warnings thrown by the solc 0.7.4 compiler: "Warning: This declaration shadows an existing declaration." 1. Arguments by default are not underscored. 2. If the name isn't available due to shadowing, use prefix underscore. 3. If prefix underscore isn't available due to shadowing, use suffix underscore.
909216a to
106be12
Compare
|
@frangio I've removed previous commit and added new commit based on the followed conventions. Can you please have a look? |
frangio
left a comment
There was a problem hiding this comment.
Awesome work, thank you!
Fixes #2391
This PR aims to remove plenty of warnings that show up when compiling contracts with solc
0.7.4.There were three kinds of warnings:
To prevent declaration shadowing, contract method arguments are suffixed with an underscore. Given that
namenaming is generally used for public vars or functions and_namenaming for private vars or functions. Just to mention, this convention is already present in OpenZeppelin contracts and many other projects use this convention. Also, many devs use underscore prepending to function args to prevent shadowing but since solc 0.7.4, the compiler highlights if that shadows functions too (which were missed before). So having an alternate convention for arguments easily solves the problem. Inspired from here, the convention of havingname_naming for function arguments to prevent shadowing is taken in this PR in the first commit.The second commit tries to silence this warning.
The third commit simply changes
viewtopure.Please let me know if this is fine or any changes that need to be done.