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, x/tools/go/ssa: panic: type param without replacement encountered #63260

Closed
josharian opened this issue Sep 27, 2023 · 7 comments
Closed
Assignees
Labels
NeedsFix The path to resolution is known, but the work has not been done. release-blocker Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@josharian
Copy link
Contributor

Run ssa.(*Program).Build on this module (for us, via govulncheck):

go.mod, does not reproduce with go 1.20:

module z

go 1.21

main.go, simplified from real code:

package main

func main() {
	use(f[*string])
}

func use(fn func() any) {}

func f[I interface{ *T }, T any]() any {
	var z T
	return z
}

Result:

panic: type param without replacement encountered

Reproduced with x/tools v0.13.0 and master as of Sep 27, 2023.

cc @alandonovan

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 27, 2023
@gopherbot gopherbot added this to the Unreleased milestone Sep 27, 2023
@findleyr
Copy link
Contributor

Reproducer:
https://go.dev/play/p/LI7HtjPdNqe

Running on 1.21 yields "T false", yet on 1.20 yields "T true". Per @timothy-king all that matters in the go.mod language version, so it may relate to new unification logic. Note that if you comment out the inferred use in main, you get "T true" again.

CC @griesemer -- this is a go/types bug.

@findleyr
Copy link
Contributor

My guess: something in the new unification logic is mutating the generic type.

@findleyr findleyr modified the milestones: Unreleased, Go1.21.3 Sep 28, 2023
@findleyr findleyr added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Sep 28, 2023
@findleyr findleyr assigned griesemer and findleyr and unassigned timothy-king Sep 28, 2023
@griesemer
Copy link
Contributor

Type inference does parameter renaming. It may record the renamed type parameters.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/532157 mentions this issue: go/types, types2: don't implicitly modify an argument function's type

@griesemer
Copy link
Contributor

@gopherbot please consider this for backport to 1.21.3. This is a type-checker bug.

@gopherbot
Copy link
Contributor

Backport issue(s) opened: #63339 (for 1.21).

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

@dmitshur
Copy link
Contributor

dmitshur commented Oct 2, 2023

Moving this to the Go 1.22 milestone to track the fix at tip, and copying @findleyr's release-blocker label to the backport issue (which now tracks the fix for Go 1.21.3). Please feel free to remove that label if it's no longer needed.

(Edit: Sorry for initially CCing you Robin.)

@dmitshur dmitshur modified the milestones: Go1.21.3, Go1.22 Oct 2, 2023
@dmitshur dmitshur changed the title x/tools/go/ssa: panic: type param without replacement encountered go/types, x/tools/go/ssa: panic: type param without replacement encountered Oct 2, 2023
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done. release-blocker Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

6 participants