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

mdempsky opened this issue Jun 6, 2021 · 2 comments


Copy link

@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

Copy link

@griesemer griesemer commented Jun 6, 2021

Nice idea. CL forthcoming.

Copy link

@gopherbot gopherbot commented Jun 6, 2021

Change 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

For #46594.

Change-Id: I53776cbdc1b8f6da511abe2c6659a7313d7a163a
Trust: Robert Griesemer <>
Run-TryBot: Robert Griesemer <>
TryBot-Result: Go Bot <>
Reviewed-by: Matthew Dempsky <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants