diff options
| author | Michael Stapelberg <michael@stapelberg.de> | 2013-03-23 11:29:06 +0100 |
|---|---|---|
| committer | Michael Stapelberg <michael@stapelberg.de> | 2013-03-23 11:29:06 +0100 |
| commit | cc71238f4c5d23ee2ebffd0d6c307e308ea163c1 (patch) | |
| tree | dd0b57254871fac715258385f5485ba136d6b62a /src/cmd/vet/test_assign.go | |
| parent | b32e37d71adab0e2a2b7c4433e7bad169a9a4f98 (diff) | |
| parent | b39e15dde5ec7b96c15da9faf4ab5892501c1aae (diff) | |
| download | golang-cc71238f4c5d23ee2ebffd0d6c307e308ea163c1.tar.gz | |
Merge tag 'upstream/1.1_hg20130323' into debian-sid
Upstream version 1.1~hg20130323
Diffstat (limited to 'src/cmd/vet/test_assign.go')
| -rw-r--r-- | src/cmd/vet/test_assign.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/cmd/vet/test_assign.go b/src/cmd/vet/test_assign.go new file mode 100644 index 000000000..8e0f45e53 --- /dev/null +++ b/src/cmd/vet/test_assign.go @@ -0,0 +1,20 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file contains tests for the useless-assignment checker. + +// +build vet_test + +package main + +type ST struct { + x int +} + +func (s *ST) SetX(x int) { + // Accidental self-assignment; it should be "s.x = x" + x = x // ERROR "self-assignment of x to x" + // Another mistake + s.x = s.x // ERROR "self-assignment of s.x to s.x" +} |
