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: panics with generic type alias and based-on constraint #68580

Closed
splace opened this issue Jul 24, 2024 · 11 comments
Closed

cmd/compile: panics with generic type alias and based-on constraint #68580

splace opened this issue Jul 24, 2024 · 11 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@splace
Copy link

splace commented Jul 24, 2024

Go version

1.23rc1

Output of go env in your module/workspace:

n/a

What did you do?

https://go.dev/play/p/kMvT8_f91aK?v=gotip

What did you see happen?

: internal compiler error: panic: /usr/local/go/src/cmd/compile/internal/types2/subst.go:56: assertion failed

etc.

What did you expect to see?

no panic

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 24, 2024
@ianlancetaylor
Copy link
Contributor

CC @griesemer @timothy-king

@griesemer griesemer self-assigned this Jul 24, 2024
@griesemer
Copy link
Contributor

Reproduced at 1.23rc2. Interestingly, the code typechecks fine when checked by the typechecker alone.

@timothy-king
Copy link
Contributor

Reduced example: https://go.dev/play/p/X9GxAbUdgeA?v=gotip

@griesemer
Copy link
Contributor

griesemer commented Jul 24, 2024

Simpler reproducer (link):

package main

type A[P any] = struct{ _ P }

type N[P any] A[P]

func f[P any](N[P]) {}

var _ = f[int]

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/601115 mentions this issue: types2, go/types: fix instantiation of named type with generic alias

@cuonglm
Copy link
Member

cuonglm commented Jul 26, 2024

@griesemer Do we need to backport this to 1.23?

@dmitshur dmitshur added this to the Go1.24 milestone Jul 26, 2024
@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 26, 2024
@cuonglm
Copy link
Member

cuonglm commented Jul 26, 2024

@gopherbot please backport this issue to go1.23

@gopherbot
Copy link
Contributor

Backport issue(s) opened: #68608 (for 1.23).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@griesemer
Copy link
Contributor

@cuonglm Yes, we should backport this. I believe an issue is not needed per @dmitshur 's e-mail:

Any CLs that land after CL 600176 ("internal/goversion: update Version to 1.24") but target Go 1.23 must be cherry-picked to release-branch.go1.23. Cherry-pick CLs can be created following the same steps as usual but do not need a backport issue or approval from the release team. Please continue to use your judgment about what should be included this late in the Go 1.23 release cycle.

@dmitshur dmitshur modified the milestones: Go1.24, Go1.23 Jul 26, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/601116 mentions this issue: [release-branch.go1.23] types2, go/types: fix instantiation of named type with generic alias

gopherbot pushed a commit that referenced this issue Jul 26, 2024
…type with generic alias

The typechecker is assuming that alias instances cannot be reached from
a named type. However, when type parameters on aliases are permited, it
can happen.

This CL changes the typechecker to propagate the correct named instance
is being expanded.

Updates #46477
Fixes #68580

Change-Id: Id0879021f4640c0fefe277701d5096c649413811
Reviewed-on: https://go-review.googlesource.com/c/go/+/601115
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/601116
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

8 participants