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: internal compiler error when compiling code with unbound method of generic type [1.19 backport] #54243

Closed
gopherbot opened this issue Aug 3, 2022 · 4 comments
Assignees
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge
Milestone

Comments

@gopherbot
Copy link

@randall77 requested issue #53982 to be considered for backport to the next 1.19 minor release.

@gopherbot Please open a backport issue for 1.19.

@gopherbot gopherbot added the CherryPickCandidate Used during the release process for point releases label Aug 3, 2022
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Aug 3, 2022
@gopherbot gopherbot added this to the Go1.19.1 milestone Aug 3, 2022
@randall77
Copy link
Contributor

From #53852 (comment) , we avoided backporting generics fixes because they tended to be destabilizing.

I suspect we will want to do something similar for 1.20, especially once we switch over to unified IR, at which point any fixes for 1.19 will be different from fixes for tip.

But for now I think the CL for this issue is simple enough to warrant a backport.

This is an ICE caused by embedding a generic type and calling a method on that type.

@jmacd
Copy link

jmacd commented Aug 5, 2022

We suspect this is related, here's a way to reproduce:
https://go.dev/play/p/R_wq9G9RIFV

@joedian joedian added the CherryPickApproved Used during the release process for point releases label Aug 10, 2022
@gopherbot gopherbot removed the CherryPickCandidate Used during the release process for point releases label Aug 10, 2022
@gopherbot
Copy link
Author

Change https://go.dev/cl/423114 mentions this issue: [release-branch.go1.19] cmd/compile: fix wrong typeparams for selector expr with embedded generic type

@gopherbot
Copy link
Author

Closed by merging 16c2b36 to release-branch.go1.19.

gopherbot pushed a commit that referenced this issue Aug 17, 2022
…r expr with embedded generic type

For selector expression "x.M" where "M" is a promoted method, irgen is using
the type of receiver "x" for determining the typeparams for instantiation.
However, because M is a promoted method, so its associated receiver is
not "x", but "x.T" where "T" is the embedded field of "x". That casues a
mismatch when converting non-shape types arguments.

Fixing it by using the actual receiver which has the method, instead of
using the base receiver.

Fixes #54243

Change-Id: I1836fc422d734df14e9e6664d4bd014503960bfc
Reviewed-on: https://go-review.googlesource.com/c/go/+/419294
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/423114
Reviewed-by: Carlos Amedee <carlos@golang.org>
bradfitz pushed a commit to tailscale/go that referenced this issue Sep 8, 2022
…r expr with embedded generic type

For selector expression "x.M" where "M" is a promoted method, irgen is using
the type of receiver "x" for determining the typeparams for instantiation.
However, because M is a promoted method, so its associated receiver is
not "x", but "x.T" where "T" is the embedded field of "x". That casues a
mismatch when converting non-shape types arguments.

Fixing it by using the actual receiver which has the method, instead of
using the base receiver.

Fixes golang#54243

Change-Id: I1836fc422d734df14e9e6664d4bd014503960bfc
Reviewed-on: https://go-review.googlesource.com/c/go/+/419294
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/423114
Reviewed-by: Carlos Amedee <carlos@golang.org>
@golang golang locked and limited conversation to collaborators Aug 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

4 participants