Is this really an expected or easy to remember feature:
#proc p(a = 2; b = 2): int =
proc p(a, b: int = 2): int =
#var a = a
#var b = b
var a, b: int
#(a, b) = (a, b)
a = a; b = b
return a + b
proc main =
echo p()
main()
I did this short test as a result of the other recent thread -- so var a = a creates a local copy, but var a: int; a = a does not.
There is no compiler warning. Well we can remember that, but unfortunately the tuple copy (a, b) = (a, b) can not be used for long parameter lists.
When you write var a = a, there is no local variable a in scope yet, so the (new) a gets assigned the value of the parameter a.
When you write var a: int, you introduce a local variable a that shadows the parameter, and then a = a is a no-op