1
0
mirror of https://github.com/golang/go synced 2024-11-15 03:20:31 -07:00
go/test/fixedbugs/issue56768.go
Cuong Manh Le 81c9b1d65f cmd/compile: fix broken IR for iface -> eface
For implementing interface to empty interface conversion, the compiler
generate code like:

	var res *uint8
	res = itab
	if res != nil {
		res = res.type
	}

However, itab has type *uintptr, so the assignment is broken. The
problem is not shown up, until CL 450215, which call typecheck on this
broken assignment.

To fix this, just cast itab to *uint8 when doing the conversion.

Fixes #56768

Change-Id: Id42792d18e7f382578b40854d46eecd49673792c
Reviewed-on: https://go-review.googlesource.com/c/go/+/451256
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-11-17 19:55:28 +00:00

38 lines
441 B
Go

// compile
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package p
type I interface {
M()
}
type slice []any
func f() {
ss := struct{ i I }{}
_ = [...]struct {
s slice
}{
{
s: slice{ss.i},
},
{
s: slice{ss.i},
},
{
s: slice{ss.i},
},
{
s: slice{ss.i},
},
{
s: slice{ss.i},
},
}
}