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 Interface.Embedded to panic instead of returning nil for non-defined types #46423

Open
mdempsky opened this issue May 27, 2021 · 0 comments
Assignees
Milestone

Comments

@mdempsky
Copy link
Member

@mdempsky mdempsky commented May 27, 2021

Last night I ran into an issue where I'd called Embedded(i) instead of EmbeddedType(i), and it took me a little while to realize the mistake. The issue instead manifested as nil-pointer panic elsewhere from trying to use the Type((*Named)(nil)) value I had inadvertently constructed. I think the mistake would have been easier and quicker to identify if Embedded(i) had simply panicked instead.

I think this is relevant to Go 1.18 because the introduction of generics and union types will probably increase the need for using EmbeddedType instead of Embedded. (Today, EmbeddedType is only needed when a type alias is used to embed an anonymous interface.)

/cc @griesemer @findleyr

@mdempsky mdempsky added this to the Go1.18 milestone May 27, 2021
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