testdata: add generic alias identity regressions

Add cases where same-named local aliases instantiate generic functions,
local types, and methods with float32 and float64. Record the current
collisions and incorrect results.
This commit is contained in:
Jake Bailey
2026-07-12 13:28:44 -07:00
committed by Ron Evans
parent 6d49f0177b
commit 73db9776b1
4 changed files with 215 additions and 18 deletions
+37
View File
@@ -19,12 +19,49 @@ func Add[T Coord](a, b Point[T]) Point[T] {
}
}
func aliasSize[F float32 | float64]() uintptr {
return unsafe.Sizeof(F(0))
}
func aliasSize32() uintptr {
type F = float32
return aliasSize[F]()
}
func aliasSize64() uintptr {
type F = float64
return aliasSize[F]()
}
type aliasMethodResult[F float32 | float64] struct {
Value F
}
type aliasMethodValue[F float32 | float64] struct{}
func (aliasMethodValue[F]) Get() aliasMethodResult[F] {
return aliasMethodResult[F]{}
}
func main() {
var af, bf Point[float32]
Add(af, bf)
var ai, bi Point[int]
Add(ai, bi)
checkSize(aliasSize32())
checkSize(aliasSize64())
}
func checkSize(uintptr)
func checkBool(bool)
func aliasMethod32(x any) {
type F = float32
_, ok := x.(interface {
Get() aliasMethodResult[F]
})
checkBool(ok)
}