Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: generic function instantiated with wrong type #48253

Closed
korzhao opened this issue Sep 8, 2021 · 2 comments
Closed

cmd/compile: generic function instantiated with wrong type #48253

korzhao opened this issue Sep 8, 2021 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@korzhao
Copy link
Contributor

korzhao commented Sep 8, 2021

What version of Go are you using (go version)?

go tip 1.18

$ go version

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?

package main

import (
	"fmt"
	"reflect"
)

type A[T any] struct {
	B[int]
}
type B[T any] struct {
}
func (b B[T]) Bat() {
	t := new(T)
	fmt.Println(reflect.TypeOf(t).String())
}

type Foo struct {
	A[string]
}
func main() {
	Foo{}.A.Bat()
	Foo{}.A.B.Bat()
}

What did you expect to see?

*int
*int

What did you see instead?

*string
*int
@cuonglm
Copy link
Member

cuonglm commented Sep 8, 2021

Unified IR works right:

$ GOEXPERIMENT=unified go run p.go
*int
*int

@cuonglm cuonglm added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 8, 2021
@cuonglm cuonglm added this to the Go1.18 milestone Sep 8, 2021
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/348549 mentions this issue: cmd/compile: fix wrong instantinated type for embedded receiver

@golang golang locked and limited conversation to collaborators Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants