-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add types.Unalias
to types assertions and types switches to get an underlying type instead of types.Alias
#33868
Conversation
…into go-type-unaliasing
…et an underlying type instead of types.Alias
…et an underlying type instead of types.Alias
…into go-type-unaliasing
Assigning reviewers. If you would like to opt out of this review, comment R: @lostluck for label go. Available commands:
The PR bot will only process comments in the main thread (not review comments). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the other comments are the main concerns: We don't want to generate code with underlying/aliased types, we want to use the aliased types for naming things.
There's certainly value in the cases where an alias could be made instead of the raw code. The Unalias handling would have been great when this was originally written, and would have lead to a different approach, had it existed pre generics at all.
However, as I said in my other message: There isn't a great deal of value in fixing this code: users should be migrating to the generic register package, vs trying to use this belabored code generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Hi,
I've just sent a fix for this. But there is another problem too.
When I run tests I can see that `
github.com/apache/beam/sdks/v2/go/test/integration/io/mongodbio` fails with
"panic: checked path: $XDG_RUNTIME_DIR" and I'm not sure why.
…On Wed, Feb 19, 2025 at 3:26 PM Robert Burke ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In sdks/go/pkg/beam/util/starcgenx/starcgenx.go
<#33868 (comment)>:
> if t, ok := t.(*types.Named); ok {
- if pkg := t.Obj().Pkg(); pkg != nil {
+ e.Printf("extractType: adding import path %q for %v\n", pkg.Path(), t)
This should be inside the following if block. Pkg isn't defined yet .
—
Reply to this email directly, view it on GitHub
<#33868 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXKYBXAZJ36LXBHPBAMIY4D2QSIARAVCNFSM6AAAAABWRN622CVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDMMRWHE4DQNBUGQ>
.
You are receiving this because you authored the thread.Message ID:
<apache/beam/pull/33868/review/2626988444 ***@***.***>
|
That seems like a flake or local misconfiguration. I wouldn't worry about it. Some of the tests aren't set up to run standalone with the go tool, but with the Gradle wrapper the repo uses. Just need to run go fmt on shimgenx.go and this will be done. |
Sorry i meant starcgenx.go. |
types.Unlias
to types assertions and types switches to get an underlying type instead of types.Aliastypes.Unalias
to types assertions and types switches to get an underlying type instead of types.Alias
fyi: I'll remove the log line that causes this error: "Error: util/starcgenx/starcgenx.go:521:67: types.Rhs requires go1.23 or later (file is go1.22)" |
#34039 fixes the missing edge case here where alias types might not get registered properly, leading to no code generated for them. |
…underlying type instead of types.Alias (apache#33868)
Go 1.24's types package changes type representation: types created as aliases would be represented by
types.Alias
instead of its underlying type as before. This requires updates to any code using go/types. Specifically, types.Unalias(t) may be needed before type assertions/switches to handle aliases.Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.