-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: compiler panics on key-element slice literal with float index #16439
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
Comments
I've sent a CL https://go-review.googlesource.com/#/c/25081. |
CL https://golang.org/cl/25081 mentions this issue. |
That was fast; I opened the issue to provide a reference to a patch I wanted to mail (it's CL 25090, gobot didn't reference it here since I closed it with R=go1.8). Well, we can now choose between two different fixes. |
FWIW, I prefer CL 25090. nonnegconst could use a bit of cleanup, but that's unrelated...and that's true for much of the compiler. |
Thanks @ALTree. @josharian aye aye, yap I now see that too, CL 25090 is smaller, less invasive and will prevent other crashes that slip through in that check. I considered one like it but thought I could somewhat improve the message since 'non-negative integer' seems like a catch all statement IMO but it might just be sufficient. |
@odeke-em yep, I think it's sufficient. I'm thrilled to see more folks working on the compiler, though. Please keep sending CLs! |
Cool, I'll close my CL in favor of 25090 and we can move work to it. Awesome, I look forward to doing work on the compiler. |
For the record, a positive floating-point constant representable as an integer (e.g., 2.0) is permissible. Same for complex numbers representable as an integer (e.g., 2.0 + 0i). See my comments on https://go-review.googlesource.com/#/c/25090 . |
CL https://golang.org/cl/29011 mentions this issue. |
The compiler knows that you must use an integer constant as an index for a key-element literal, and the error message is fine when a negative index is used:
but the compiler panics when a float is used:
The text was updated successfully, but these errors were encountered: