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

proposal: vet should catch shadowing of predeclared identifiers #33567

seebs opened this issue Aug 9, 2019 · 2 comments


Copy link

commented Aug 9, 2019

(Related: #31064, #14494)

What version of Go are you using (go version)?

1.12, but N/A

Does this issue reproduce with the latest release?

I believe so?

What operating system and processor architecture are you using (go env)?


What did you do?

Horrible monstrous things. Examples:

const iota = 0
type int struct{}
var nil = "haha"

Okay, fine, those are stupid. But you know what I've done unintentionally?

len := a -b
for i := 0; i < len(x); i++ {

and then get confused by the weird error message about len not being a function.

What did you expect to see?

I think redeclaring predeclared identifiers should be an error. Or, since that's probably impractical, it should be a thing in go vet.

What did you see instead?

Really weird and misleading error messages when I forget that something is a predeclared identifier. I've hit this most often with len, because that's a natural variable name and when I'm naming something that I'm usually not thinking about the function.

@gopherbot gopherbot added this to the Proposal milestone Aug 9, 2019

@gopherbot gopherbot added the Proposal label Aug 9, 2019


This comment has been minimized.

Copy link

commented Aug 9, 2019

See also #31064 and #21606.


This comment has been minimized.

Copy link

commented Aug 9, 2019

This particular case of shadowing is no different in kind from the general issue. We should be able to close this in deference to the ones linked above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.