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

go/types, cmd/compile/internal/types2: uninstantiated method in assignment check #46275

findleyr opened this issue May 19, 2021 · 3 comments


Copy link

@findleyr findleyr commented May 19, 2021

Consider the following:

package main

type N[T any] struct {
        t T

func (n *N[T]) Elem() T {
        return n.t

type I interface {
        Elem() string

func main() {
        var n1 *N[string]
        var _ I = n1
        type NS N[string]
        var n2 *NS
        var _ I = n2

This program should type-check cleanly, but does not. The type parameter is unsubstituted in the assignability check: cannot use n2 (variable of type *NS) as I value in variable declaration: wrong type for method Elem (have func() T, want func() string).

CC @griesemer

@findleyr findleyr added this to the Go1.18 milestone May 19, 2021
@findleyr findleyr self-assigned this May 19, 2021
Copy link

@griesemer griesemer commented May 19, 2021

This fails in lookup.go, Checker.missingMethod, in the unify phase around lines 420. There's a TODO, this code may not be correct.

Copy link

@gopherbot gopherbot commented May 19, 2021

Change mentions this issue: [dev.typeparams] cmd/compile/internal/types2: use correct type parameter list in missingMethod

gopherbot pushed a commit that referenced this issue May 19, 2021
…ter list in missingMethod

For #46275

Change-Id: Iaed9d8ba034ad793e5c57f2be174f01a535fee95
Trust: Robert Griesemer <>
Reviewed-by: Robert Findley <>
Copy link

@gopherbot gopherbot commented Jun 3, 2021

Change mentions this issue: [dev.typeparams] go/types: use correct type parameter list in missingMethod

gopherbot pushed a commit that referenced this issue Jun 4, 2021

This is a port of CL 321232 to go/types, adjusted to add a missing
comment and to remove optional support for method type params.

Fixes #46275

Change-Id: I63fcbb669e7607876a888fca89b9064568805448
Trust: Robert Findley <>
Run-TryBot: Robert Findley <>
TryBot-Result: Go Bot <>
Reviewed-by: Robert Griesemer <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants