Fixes #15118
Change-Id: Iad56ed412535c8ac0a01c4bd7769fd3d37688ac9
Reviewed-on: https://go-review.googlesource.com/21526
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
if len(n.Lhs) != len(n.Rhs) {
return
}
+ if len(n.Lhs) == 1 && n.Tok == token.DEFINE {
+ return
+ }
for i, right := range n.Rhs {
call, ok := right.(*ast.CallExpr)
*ap[1] = atomic.AddUint64(ap[0], 1)
x = atomic.AddUint64() // Used to make vet crash; now silently ignored.
+
+ {
+ // A variable declaration creates a new variable in the current scope.
+ x := atomic.AddUint64(&x, 1) // ERROR "declaration of .x. shadows declaration at testdata/atomic.go:16"
+
+ // Re-declaration assigns a new value.
+ x, w := atomic.AddUint64(&x, 1), 10 // ERROR "direct assignment to atomic value"
+ _ = w
+ }
}