-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: imperfect error message for too large index in slice composite literal #23781
Comments
And this:
|
This happens because the
The key you used fails the last check ( The problem here is that AFAIK we can't just easily remove the check above, because there are several places in the compiler (both in the frontend and the backend) where those values are assumed to be |
I guess we could change I'll send a patch for 1.11 if this sounds good. There's still an issue with the spec wording, but at least we'll have a better error message. |
FWIW, both go/types and gccgo accept this code w/o problems. gccgo can also run it (again w/o problems). |
Change https://golang.org/cl/151599 mentions this issue: |
What version of Go are you using (
go version
)?go version go1.9.3 linux/amd64
Does this issue reproduce with the latest release?
yes
What did you do?
What did you expect to see?
compile ok, or with error
What did you see instead?
fail to compile, with error
From Go spec. (in array and slice literals)
1 << 31
is representable by a value of type int on 64-bit OS, and it is non-negative.The text was updated successfully, but these errors were encountered: