Skip to content

compiler fails to detect unimplemented method for embedded interface in struct, causing panic: invalid memory address or nil pointer dereference #6238

@gopherbot

Description

@gopherbot

by cyle@riggsfamilyweb.net:

Before filing a bug, please check whether it has been fixed since the
latest release. Search the issue tracker and check that you're running the
latest version of Go:

Run "go version" and compare against
http://golang.org/doc/devel/release.html  If a newer version of Go exists,
install it and retry what you did to reproduce the problem.

Thanks.

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. http://play.golang.org/p/cvmtnB4NoX

What is the expected output?
Some error about a missing/unimplemented method

What do you see instead?
Program compiles and runs with panic:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x203c]

goroutine 1 [running]:
main.main()
    /Users/cyler/src/gobug/bug.go:13 +0x3c

goroutine 2 [runnable]:
exit status 2


Which compiler are you using (5g, 6g, 8g, gccgo)?
 ~/src/gobug $ go version
go version go1.1.2 darwin/amd64

Which operating system are you using?
OS X 10.8.4 Darwin Kernel Version 12.4.0: Wed May  1 17:57:12 PDT 2013;
root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64

Which version are you using?  (run 'go version')
 ~/src/gobug $ go version
go version go1.1.2 darwin/amd64

Please provide any additional information below.

Notes:
If the interface embedded in the struct is in a different file than the struct itself
the stack dump for the panic reports a call at line 0 of the file which defines the
interface.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions