go version devel go1.18-9e6ad46bcc Sun Nov 7 04:57:22 2021 +0000 linux/amd64
Given https://play.golang.org/p/wsCMMD9Jk9J compiled with -gcflags='-N -l' the method PushBack compiles to:
TEXT main.(*List[go.shape.int_0]).PushBack(SB) ./buggy.go
...
buggy.go:22 0x454a90 488b00 MOVQ 0(AX), AX
buggy.go:31 0x454a93 8400 TESTB AL, 0(AX)
buggy.go:22 0x454a95 c6400801 MOVB $0x1, 0x8(AX)
...
The instruction 0x454a93 gets assigned to a line outside of the PushBack function, in this case it's the call to PushBack but in more complex examples can be something completely unrelated. Can't make this happen without embedding and type parameters.
cc @dr2chase
go version devel go1.18-9e6ad46bcc Sun Nov 7 04:57:22 2021 +0000 linux/amd64Given https://play.golang.org/p/wsCMMD9Jk9J compiled with
-gcflags='-N -l'the method PushBack compiles to:The instruction 0x454a93 gets assigned to a line outside of the PushBack function, in this case it's the call to PushBack but in more complex examples can be something completely unrelated. Can't make this happen without embedding and type parameters.
cc @dr2chase