Zokrates / ZoKrates

A toolbox for zkSNARKs on Ethereum
https://zokrates.github.io
GNU Lesser General Public License v3.0
1.83k stars 361 forks source link

Immutability by default #1159

Closed dark64 closed 2 years ago

dark64 commented 2 years ago

Motivation

This feature is a part of the roadmap. If you forget to flag a variable as mut, the compiler should catch it, and let you know that you have mutated something you may not have intended to mutate.

Specification

Add mut modifier to the grammar and declaration statement. In semantics check if variables are mut or not, and allow assignments only on mutable ones.

Example:

field mut a = 0
a = 1 // allowed

field b = 0
b = 1 // not allowed

Backwards Compatibility

Seems like a breaking change.

Schaeff commented 2 years ago

1168