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: cmd/vet: warn about builtin assignment #42851
Comments
What is the harm in using |
Yes, you are right about there is no harm. |
They are identifiers. Identifier shadowing is also allowed for other identifiers in Go.
Vet is not a code style enforcer: "Vet's checks are about correctness, not style." As far as I understand the vet argument checking in fmt actually covers code that is considered an error by fmt. Reusing identifiers is not an error as shown by the standard library. I think its fine if developers opt in to disallow shadowing some identifiers in style checkers on their codebase. Making it a defacto enforced style in Go seems a big hammer. If that path is taken of disallowing to reuse those identifiers (kind of a language change in disguise) it might just be better to make them compile errors. (I am not in favor of disallowing shadowing of builtin identifiers.) |
Fair point, let linter do their job since shadowing is not an error. |
This is a proposal that adding check on builtin assignment to vet.
For example:
All are valid by the compiler and vet now.
We might warn about these kind of overwritten for clarification.
Go itself has ~200 overwritten
builtin_overwritten.log
The text was updated successfully, but these errors were encountered: