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: change (*types.Package)(nil).Scope() to return types.Universe instead of panicking #46594

Closed
mdempsky opened this issue Jun 6, 2021 · 5 comments
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@mdempsky
Copy link
Member

mdempsky commented Jun 6, 2021

Maybe because I'm accustomed to working in cmd/compile where we represent the universe as a package, but I find myself often writing obj.Pkg().Scope(), which then fails for predeclared objects. So I always end up having to go back and change it to explicitly check the obj.Pkg() result for nil and to use types.Universe instead.

It would be a nice convenience IMO if (*types.Package)(nil).Scope() just evaluated to types.Universe instead.

/cc @griesemer @findleyr @dominikh

@mdempsky mdempsky added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jun 6, 2021
@griesemer
Copy link
Contributor

Nice idea. CL forthcoming.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/325469 mentions this issue: [dev.typeparams] cmd/compile/internal/types2: return Universe for ((*Package)(nil)).Scope()

gopherbot pushed a commit that referenced this issue Jun 6, 2021
…Package)(nil)).Scope()

For #46594.

Change-Id: I53776cbdc1b8f6da511abe2c6659a7313d7a163a
Reviewed-on: https://go-review.googlesource.com/c/go/+/325469
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
@mdempsky mdempsky added this to the Go1.19 milestone Feb 15, 2022
@mdempsky
Copy link
Member Author

Porting the unified IR importer from types2 to go/types exposed that we never made the corresponding change for this to go/types. I think it's too late to make this change for Go 1.18, but I suggest we make it for Go 1.19. (If acceptable, I have a CL for this already in my local stack of unified IR CLs.)

@findleyr
Copy link
Contributor

This is a great idea, and totally fine to do in 1.19.

CC @marwan-at-work, as this is relevant to a recent discussion...

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/385997 mentions this issue: go/types: return Universe for (*Package)(nil).Scope()

@golang golang locked and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

4 participants