3 ms·
Another example (fixable): package main import "unsafe" //go:fix inline func foo[T any]() { var t T _ = 1 / unsafe.Sizeof(t)
by tapirl 7mo ago
Another example (fixable):
package main
import "unsafe"
//go:fix inline
func foo[T any]() {
var t T
_ = 1 / unsafe.Sizeof(t)
}
func main() {
foo[struct{}]()
}
Go is a language full of details: https://go101.org/details-and-tips/101.html https://go101.org/details-and-tips/101.html
- tapirl 7mo agosimilar: package main //go:fix inline func foo[T [8]byte | [4]uint16]() { var v T var n byte = 1 << len(v) >> len(v) if n == 0 { println("T is [8]byte") } else { println("T is [4]uint16]") } } func main() { foo[[8]byte]() }
- tapirl 7mo agoanother: package main type T = [8]byte var a T //go:fix inline func foo() T { return T{} } func main() { if foo() == a { } } filed: https://github.com/golang/go/issues/78170 https://github.com/golang/go/issues/78170 and https://github.com/golang/go/issues/78169 https://github.com/golang/go/issues/78169