We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
go version
$ go version go version devel go1.18-91abe4be0e Sat Nov 20 08:47:36 2021 +0000 darwin/arm64
package main import "constraints" func shl[I constraints.Integer](n I) I { return 1 << n } func main() {}
Successful compilation, because the non-generic function would compile for all types covered by constraints.Integer.
constraints.Integer
./prog.go:6:9: invalid operation: shifted operand 1 (type I) must be integer
The generic function compiles with an explicit type conversion:
func shl[I constraints.Integer](n I) I { return I(1) << n }
The text was updated successfully, but these errors were encountered:
Change https://golang.org/cl/365895 mentions this issue: cmd/compile/internal/types2: use allInteger to check type for shifted operand
cmd/compile/internal/types2: use allInteger to check type for shifted operand
Sorry, something went wrong.
ffb6c79
No branches or pull requests
What version of Go are you using (
go version
)?What did you do?
What did you expect to see?
Successful compilation, because the non-generic function would compile for all types covered by
constraints.Integer
.What did you see instead?
The generic function compiles with an explicit type conversion:
The text was updated successfully, but these errors were encountered: