Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/vet: `s = append(s)` should warn #15117

Closed
keyneston opened this issue Apr 4, 2016 · 3 comments
Closed

cmd/vet: `s = append(s)` should warn #15117

keyneston opened this issue Apr 4, 2016 · 3 comments
Milestone

Comments

@keyneston
Copy link

@keyneston keyneston commented Apr 4, 2016

  1. What version of Go are you using (go version)?
go version
go version go1.6 darwin/amd64
  1. What operating system and processor architecture are you using (go env)?
$ go env
GOARCH="amd64"
GOBIN="/Users/tarrant/Code/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/tarrant/Code"
GORACE=""
GOROOT="/Users/tarrant/Code/src/github.com/golang/go"
GOTOOLDIR="/Users/tarrant/Code/src/github.com/golang/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
  1. What did you do?

I accidently wrote something along the lines of the following code. It surprised me that vet didn't report his as an error.

var s []int
s = append(s)

https://play.golang.org/p/xxFTTzhl14

  1. What did you expect to see?

I expect vet to report this as an error. This code is a complete noop as far as I know.

@mdempsky mdempsky changed the title vet: `s = append(s)` should warn cmd/vet: `s = append(s)` should warn Apr 4, 2016
@mdempsky

This comment has been minimized.

Copy link
Member

@mdempsky mdempsky commented Apr 4, 2016

/cc @robpike

@bradfitz bradfitz added this to the Unreleased milestone Apr 4, 2016
@minux

This comment has been minimized.

Copy link
Member

@minux minux commented Apr 4, 2016

@robpike

This comment has been minimized.

Copy link
Contributor

@robpike robpike commented Apr 5, 2016

Agree. See cmd/vet/README for adoption criteria.

@robpike robpike closed this Apr 5, 2016
@golang golang locked and limited conversation to collaborators Apr 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.