1
0
mirror of https://github.com/golang/go synced 2024-11-18 14:14:46 -07:00
go/cmd/vet/testdata/assign.go
Rob Pike bf87b9f0f5 go.tools/cmd/vet: use "go test" to test
- remove Makefile
- move test data into a subdirectory
- encapsulate the invocation of errchk into a standard Test using os.exec

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/9509045
2013-05-22 10:20:50 -07:00

19 lines
470 B
Go

// 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.
package testdata
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"
}