-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: allow some calls to generic functions in pre-go1.18 code #61689
Comments
Worth noting that if you duplicate It makes sense given the current limitation, but it's unfortunate to have to duplicate code like that - especially when the written syntax is literally the same. |
I totally don't get how the magic works. @mvdan, could you elaborate more on the logic? |
I just duplicated the file with the call site ( Note that opting into generics for just one file only works on Go tip (1.21) due to #59033. That doesn't work with 1.20; the entire module would need to be bumped to |
I'm aware of these facts. I just didn't got what is the difference between one After thinking for a while, I think the difference is:
|
Correct. That's why I pointed to #59033. |
The new design does complicate some use cases. |
@rogpeppe Does #61689 (comment) address your issue? (i.e. being able to duplicate the file as a workaround in Go 1.21+) |
I mentioned this workaround for the sake of exploring options, but for what it's worth I don't think it's a good solution. In most practical cases the amount of code will be significant, so you end up needing to duplicate hundreds of lines, or splitting up little bits of code into a separate file to then duplicate, which also feels awkward. |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
Is this mis-closed? |
It was marked waiting-for-info because we were waiting for info, and gopherbot has a timeout on such issues. But I agree that it should probably be left open. |
What @mvdan said. In my particular case, the duplication needed would have been a deal breaker. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?N/A
What did you do?
https://go.dev/play/p/a0oi0qhsoM1?v=gotip
What did you expect to see?
Running code.
What did you see instead?
Even though the function signature has been changed in a (mostly) backwardly compatible manner, the version-agnostic code fails to call the new version of the function, even though no code change is required to make it do so.
Perhaps we should allow calls to generic functions where they don't involve explicit generic type parameter syntax.
The text was updated successfully, but these errors were encountered: