mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 02:33:28 +00:00
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:
Vendored
+37
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user