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
spec: clarify int type used for index values of range clauses #18910
Comments
I think this is a spec bug. I think it's correct for the for statement to use the universe declaration of It's not an aliasing issue as such. Your argument works just as well for |
Good point, well spotted. |
@ianlancetaylor Agreed. Changed title accordingly. That said, it's not clear to me what the best way to address this is in the spec. There's a lot of places where we talk about type 'int' and we always mean universe's 'int' no matter what kind of shadowing declarations of 'int' are active. |
Perhaps a paragraph under "Predeclared identifiers" mentioning that whenever the spec names a predeclared identifier, that it refers to the universal declaration? |
I've looked at this a bit. Adding a paragraph to the "Predeclared identifiers" section may help if one reads the spec sequentially and keeps that paragraph in mind at all times. But that's not what people do when they have a specific question. Instead they look for the respective section in the spec. The clarification needs to be in those sections, if at all. There's many mentions of the type But more generally, we've now gone for almost 8 years and this has never come up as a problem: Readers tend to think of the predeclared types when we mention We have a more wider issue related to confusing nomenclature. Closing this one in favor of #4532. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +64c5280 Fri Feb 3 04:40:36 2017 +0000 linux/amd64
What operating system and processor architecture are you using (
go env
)?linux/amd64
What did you do?
What did you expect to see?
What did you see instead?
https://golang.org/ref/spec#For_statements says that the type of the index variable is
int
, but it looks like this is the universe declaration ofint
, not the current alias.The text was updated successfully, but these errors were encountered: