Skip to content

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

@keyneston

Description

@keyneston
  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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions