Closed
Description
What version of Go are you using (go version
)?
$ go version go version devel go1.20-b1678e508b Wed Nov 16 04:04:52 2022 +0000 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env
What did you do?
Compile following program:
package p
type I interface {
M()
}
type S struct{}
func (*S) M() {}
type slice []any
func f() {
ss := struct {
i I
}{
i: &S{},
}
_ = [...]struct {
s slice
}{
{
s: slice{ss.i},
},
{
s: slice{ss.i},
},
{
s: slice{ss.i},
},
{
s: slice{ss.i},
},
{
s: slice{ss.i},
},
}
}
What did you expect to see?
Compile ok.
What did you see instead?
/home/cuonglm/p.go:30:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment
/home/cuonglm/p.go:33:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment
/home/cuonglm/p.go:36:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment
/home/cuonglm/p.go:39:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment
/home/cuonglm/p.go:42:15: cannot use <node ITAB> (type *uintptr) as type *uint8 in assignment
The fix for #56727 reveals this bug, because it called typecheck on walked IR.
The problem is in walkConvInterface
, we generate code like:
var typeWord *uint8
typeWord = itab
But itab
has type *uintptr
. I think we can just switch itab
to *uint8
(any generic pointer type should work, I guess) cc @randall77