You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Immutable variables replace their values at deployment with compile-time constants (as inlined bytecode). This necessarily means that any getter functions for immutable value types do not view contract state and so can be defined as pure instead of view, however the compiler does not allow this.
Environment
Compiler version: 0.8.25 (and below)
Target EVM version (as per compiler settings): cancun (and others)
contractImmutableGetter {
uint256privateimmutable _releaseDate;
constructor() {
_releaseDate =block.timestamp;
}
// pure throws with ("potentially reads from environment or state"). This is lazyfunction releaseDate() publicview/* pure */returns (uint256) {
return _releaseDate;
}
}
The text was updated successfully, but these errors were encountered:
Heya @Ashraile and thanks for the issue. Now, just to be clear, we don't consider this to be a bug per-se, but the topic itself has been quite contentious and we still don't have a definitive decision on what to about the pure decorator. Some people are for the opposite of what you suggest - i.e. strengthening pure even further, but some are again the opposite of that. You can see some of the discussion in #8153. There's some further reading in the following issues as well: #12829, #9554. The reason we don't consider it a bug is because it's technically reading a state variable (which of course most would assume to mean reading from storage). I'll triage this and keep it open, since it's definitely something that could be improved upon, but as you can see from the multitude of similar issues, it's not easy to come to an agreement, so it will take some time.
Description
Immutable variables replace their values at deployment with compile-time constants (as inlined bytecode). This necessarily means that any getter functions for
immutable
value types do not view contract state and so can be defined aspure
instead ofview
, however the compiler does not allow this.Environment
Steps to Reproduce
The text was updated successfully, but these errors were encountered: