compiler: add generics test case

This test case shows a few bugs, that I will fix in subsequent patches.
This commit is contained in:
Ayke van Laethem
2022-07-28 13:21:20 +02:00
committed by Ron Evans
parent 58072a5167
commit 408855da14
3 changed files with 168 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
package main
type Coord interface {
int | float32
}
type Point[T Coord] struct {
X, Y T
}
func Add[T Coord](a, b Point[T]) Point[T] {
return Point[T]{
X: a.X + b.X,
Y: a.Y + b.Y,
}
}
func main() {
var af, bf Point[float32]
Add(af, bf)
}