Restrict variable shadowing?
Opened this issue · 0 comments
TropicSapling commented
Currently, all kinds of variable shadowing are allowed. However, this may lead to confusion and is not especially useful. Should the language perhaps instead only allow a limited form of variable shadowing, only allowing it if the newly created variable is in a deeper scope than the old? (similar to C and other languages)
Pros:
- Less confusion
Cons:
let foo = foo.unwrap
won't work for example- changing a variable from being mutable to being constant or the other way around won't work anymore, where it would previously be possible with
let mut foo = 123; let foo = foo