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: confusing error message "shift of type float64" #19963
Comments
Should this code be valid? var b uint8
_ = float64(1 << b) Currently go/types and cmd/compile both reject it. |
So I believe the error "shift of type float64" is correct because what the spec says we do is
so it's true that you are shifting a float. |
Yeah. I guess you're right. It'd be nice to make the error message a bit clearer--it happened to me in the context of a much more complex expression, but I don't really see how to. Closing for now; thanks, @ALTree . |
Yes, this is correct: The type of the |
A neat and clean compiler should show up somewhere around Go 1.x. Where I am assuming that this release will be called 1.9, the following one 1.a, then 1.b, and so on. :P |
https://play.golang.org/p/UntLLbfSoY
generates the error message
main.go:5: invalid operation: 1 << b (shift of type float64)
But there's no shift of type float64. There's a shift of type uint8. The problem is that the result of that shift needs to be converted into a float64 before multiplying.
The text was updated successfully, but these errors were encountered: