3 ms·
The spec says > Unlike regular variable declarations, a short variable declaration may redeclare variables provided they were originally declared earlier in th
by anonymoushn 5y ago
The spec says
> Unlike regular variable declarations, a short variable declaration may redeclare variables provided they were originally declared earlier in the same block (or the parameter lists if the block is the function body) with the same type, and at least one of the non-blank variables is new.
This suggests that a redeclaration as part of a short assignment will not change the type of the previously-defined err. is the spec incorrect?
Edit: Here's a demonstration of this sort of thing https://go.dev/play/p/Po_Uy85ORN_L https://go.dev/play/p/Po_Uy85ORN_L. You can uncomment line 22 to change the meaning of the assignment on line 23 and cause the program to segfault.