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

Closed
findleyr opened this issue May 19, 2021 · 3 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@findleyr
Copy link
Contributor

Consider the following:

package main

type N[T any] struct {
        *N[T]
        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 the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 19, 2021
@findleyr findleyr added this to the Go1.18 milestone May 19, 2021
@findleyr findleyr self-assigned this May 19, 2021
@griesemer
Copy link
Contributor

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

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/321232 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
Reviewed-on: https://go-review.googlesource.com/c/go/+/321232
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
@gopherbot
Copy link
Contributor

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

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants