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/compile: int is not a type #50902

Closed
chai2010 opened this issue Jan 29, 2022 · 7 comments
Closed

cmd/compile: int is not a type #50902

chai2010 opened this issue Jan 29, 2022 · 7 comments

Comments

@chai2010
Copy link
Contributor

package main

var int int

func main() {}

https://go.dev/play/p/Q_9nl4PXV-_3

@go101
Copy link

go101 commented Jan 29, 2022

By spec, the two ints are both the declared variable.

@beoran
Copy link

beoran commented Jan 29, 2022

It is true that this error message is a bit confusing.

Maybe an error message like this would be better:

/prog.go:7:9: int is not a valid variable name

@seankhliao
Copy link
Member

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@beoran
Copy link

beoran commented Jan 29, 2022

@seankhliao Maybe it is a bit soon to close this as a question? The error message really seems confusing, and I think that for Go it always has been a point of pride to provide clear error messages. Certainly in this case the message could be improved.

@seankhliao
Copy link
Member

int is a valid variable name, but declaring it as a variable precludes shadows the its predeclared definition as a type.
eg: var int bool is valid.
The character offset 9 points to that.

@seankhliao
Copy link
Member

Duplicate of #20219

@seankhliao seankhliao marked this as a duplicate of #20219 Jan 29, 2022
@beoran
Copy link

beoran commented Jan 29, 2022

Well, seeing the discussion in the liked issue i guess it is hard to improve the message. I will let it pass.

@golang golang locked and limited conversation to collaborators Jan 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants