Closed as not planned
Description
Function parameters can be marked immutable
.
Such variables are called immutable. The immutable property extends to expressions in the following way:
- members of immutable expressions are immutable
- index access to immutable expressions yields immutable expressions
- (perhaps some other cases we forgot about)
Immutable expressions cannot be assigned to (or be used in ++
or --
expressions) and they cannot be passed to internal functions as arguments that are not marked as immutable.
For value types, the "immutable" property can be removed if they are rvalues (need to specify this some more), and also the transition from storage to memory and memory to storage can lose the immutable property.
Todo:
- similar to
isPure
, collect data in the TypeChecker about whether an expression is immutable - add the immutable keyword
- check that assignments and
++
and--
do not have immutable left-hand-sides - check that there is no assignment from an immutable expression to a mutable expression
- check that arguments to function calls do not violate these rules
"The constant keyword for functions is currently not enforced by the compiler."
It sounds like Solidity can enforce this and refuse to compile.
Metadata
Metadata
Assignees
Labels
The issue/PR was automatically closed due to inactivity.A lot to implement but still doable by a single person. The task is large or difficult.Changes are very prominent and affect users or the project in a major way.Any changes to the language, e.g. new featuresThe proposal is too vague to be implemented right awayThe issue/PR was marked as stale because it has been open for too long.