Skip to content

compile: Regression in generics #73624

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

Closed
av86743 opened this issue May 7, 2025 · 4 comments
Closed

compile: Regression in generics #73624

av86743 opened this issue May 7, 2025 · 4 comments
Labels
BugReport Issues describing a possible bug in the Go implementation.

Comments

@av86743
Copy link

av86743 commented May 7, 2025

Go version

Works in 1.20.14, b0rken after 1.21.13

Output of go env in your module/workspace:

Whatever playground settings are.

What did you do?

Playground example is here.

package main

type Parser_T[a_T any] interface{}

func Base_many_6f5dd[_84T any]( /* enlhd */
	_11 Parser_T[_84T]) /* rv: */ Parser_T[_84T] {
	/* returning LazyT[Parser_T[ LazyT[ListT[ _84T ]] ]] */
	//{
	_ = Base_many_6f5dd(_11)
	panic("")
}

func main() {}

Don't bother to lecture me how "you" could "fix" this in "your" code. Those who will, better first verify how this works with reference implementation of generics.

What did you see happen?

Compilation dies with diagnostics:

./prog.go:9:21: in call to Base_many_6f5dd, cannot infer _84T (declared at ./prog.go:5:22)

Bisected using Docker golang:1.xx.yy-alpine images to fail since 1.21.13.

What did you expect to see?

Works as in original early version.

@seankhliao
Copy link
Member

I believe allowing it was a bug, see #60377

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label May 7, 2025
@av86743
Copy link
Author

av86743 commented May 7, 2025

@seankhliao Have you even looked at the sample code? Whatever was being "fixed" in #60377, has conveniently broken it. Effectively, you are now forcing users do completely unnecessary manual work, instead of allowing compiler correctly do this routine job for them as it was doing before.

The only complaints you keep getting now are that "it stopped working." There are no complaints whatsoever that it works incorrectly, or at least counter-intuitively. Entire justification of the change is based on someone's blabber that "something somewhere might go wrong..." What kind of decision making is this?

@zigo101
Copy link

zigo101 commented May 8, 2025

Custom generics introduce significant complexity, often outweighing their limited practical benefits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation.
Projects
None yet
Development

No branches or pull requests

4 participants