-
Notifications
You must be signed in to change notification settings - Fork 18k
spec: struct can implement an interface with an inherited method but attempting to call that method can cause an unexpected panic #39601
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
Comments
This is intended behavior. Dereferencing a But in a quick glance at the language spec I don't see that documented anywhere, so I guess we ought to have an additional sentence in the spec somewhere. I think the panic message is as good as it is going to get. The |
I now realize my statement
was wrong, since the panic actually states the location was in An additional line in the spec/doc would be nice though. Also, how is it even possible that |
I misspoke, my question was directed at why |
I believe this is exactly the case described in #18617. |
@finnbear
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I believe go1.14.4 is the latest stable release, so yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Playground link: https://play.golang.org/p/Xf3mskprGZV
What did you expect to see?
What did you see instead?
I suspect what is happening is that calling
IsNil
onparent
acts onparent.Child
, thus dereferencingChild
from a nil pointerparent
, but this happens silently. I think one of the following should be done:(*Child) IsNil
receiver but in the intermediate step of accessingparent.Child
The text was updated successfully, but these errors were encountered: