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

Open
mdempsky opened this issue Jun 6, 2021 · 2 comments

Comments

@mdempsky
Copy link
Member

@mdempsky 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

@griesemer
Copy link
Contributor

@griesemer griesemer commented Jun 6, 2021

Nice idea. CL forthcoming.

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 6, 2021

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants