allow immutable state variables to be named in CAPS_SNAKE_CASE
See original GitHub issueThis is more of a question than a bug report – IMO immutable variables should be allowed to be treated as constants, since they in fact cannot be changed.
Currently the code below returns a warning Variable name must be in mixedCase
when linted with the recommended ruleset.
contract Test {
uint16 public immutable TEST_MODE;
constructor(uint16 _testMode) { TEST_MODE = _testMode; }
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Solidity 0.6.x features: Saving Storage Costs with Immutables
Immutable state variables can only be assigned during contract creation, but will remain constant throughout the life-time of a deployed ...
Read more >state variable - What is the immutable keyword in Solidity?
State variables can be marked immutable which causes them to be read-only, but assignable in the constructor. The value will be stored ...
Read more >Solidity: AppStorage for distinguishing state variables and ...
AppStorage is a variable naming technique which makes state variables clear in your code and prevents name clashes with other kinds of variables...
Read more >Mutable and Immutable Objects - Manning
An object created and given a value is assigned some space in memory. The variable name bound to the object points to that...
Read more >Reading 9: Mutability & Immutability
Since String is immutable, once created, a String object always has the same ... variables named list (an instance variable and a constructor...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t know what is the state of this issue now but having support for this would be great 👍
It’s hard to think of a good single setting here, since it really concerns two rules. The simplest way would be to have some “general config” option
treat-immutable-vars-as-constants
, but that’s kinda bad design since it’s not really a general option, just a two-rule option… Maybe it will be enough to add atreat-immutable-var-as-constant: true
option to both these rules? You’d have to turn on both to have immutable variables linted inCAPS_SNAKE_CASE
, and without them it would lint them inmixedCase
.