Hi community,

We have some code that works fine in Go 1.22, but throws a compiler error 
in Go 1.23.

We've recreated the issue with a simple example:

```
package main

import (
"fmt"
)

type A = []string

func m[T ~A](a T) {
fmt.Println(a[0])
}

func main() {
b := []string{"value"}
m[A](b)

}
```

This runs fine in Go 1.22, but throws this error in Go 1.23:
./prog.go:10:15: invalid operation: cannot index a (variable of type T 
constrained by ~A)

We see something similar with maps.

Is this a compiler bug?

We've noticed that if we move the type definition of A to a package then 
it's fine in Go 1.23. Here's an example in Go playground: 
https://go.dev/play/p/l_x4F190M3y

Thanks,

Peter

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/dbafcdaf-23a1-4e4c-8104-b31236563539n%40googlegroups.com.

Reply via email to