Skip to content

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

Closed

Description

@korzhao

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

Activity

  1. cuonglm commented on Sep 8, 2021

    @cuonglm
    Member

    Unified IR works right:

    $ GOEXPERIMENT=unified go run p.go
    *int
    *int
    
  2. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Sep 8, 2021
  3. added this to the Go1.18 milestone on Sep 8, 2021
  4. gopherbot commented on Sep 8, 2021

    @gopherbot
    Contributor

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

  5. locked and limited conversation to collaborators on Sep 9, 2022
  6. added a commit that references this issue on Apr 29, 2024
    2481f6e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions