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: named type constraints that are not interfaces are not automatically embedded in implicit interfaces #50450

Closed
griesemer opened this issue Jan 5, 2022 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@griesemer
Copy link
Contributor

Test case:

func f[P ~int]() {}
func g[P int]() {}

var _ = f[int] // this is ok
var _ = g[int] // <<< ERROR int is not an interface

Per the spec, the declaration and instantiation of g should be valid.

Not a release blocker because one can always manually wrap the constraint as in:

package p

func f[P ~int]() {}
func g[P interface{int}]() {} // wrap in interface{}

var _ = f[int] // this is ok
var _ = g[int] // ok now

cc: @findleyr

@griesemer griesemer added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 5, 2022
@griesemer griesemer added this to the Go1.18 milestone Jan 5, 2022
@griesemer griesemer self-assigned this Jan 5, 2022
@griesemer griesemer changed the title cmd/compile: named type constraints that are not interfaces are not automatically embedded in implicit intercaces cmd/compile: named type constraints that are not interfaces are not automatically embedded in implicit interfaces Jan 5, 2022
@gopherbot
Copy link

Change https://golang.org/cl/375737 mentions this issue: cmd/compile/internal/types2: wrap non-interface constraints into implicit interface

jproberts pushed a commit to jproberts/go that referenced this issue Jun 21, 2022
Do this by running verification for instantiated signatures
later, after the delayed type parameter set-up had a chance
to wrap type bounds in implicit interfaces where needed.

Fixes golang#50450

Change-Id: If3ff7dc0be6af14af854830bfddb81112ac575cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/375737
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
@golang golang locked and limited conversation to collaborators Jun 22, 2023
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

2 participants