Skip to content

go.tools/go/types: nil pointer dereference for unknown types in struct definitions #5770

@dominikh

Description

@dominikh
Checking a file with a struct definition that makes use of non-existent types causes a
nil pointer dereference.

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Download attached files demo.go and broken.go into the same directory
2. go run demo.go
3.

What is the expected output?
Expected handling of the error, not an internal panic

What do you see instead?
INTERNAL PANIC: runtime error: invalid memory address or nil pointer dereference

(See attached log for complete stacktrace)

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?


Which version are you using?  (run 'go version')
go version devel +56909cb770fe Fri Jun 21 18:07:57 2013 -0700 linux/amd64

Please provide any additional information below.
In (*checker).callExpr, x.typ can be nil, which will cause typ to be nil. isUntyped(nil)
results in t, ok := typ.Underlying().(*Basic) and that's trying to call Underlying() on
nil.

Attachments:

  1. demo.go (358 bytes)
  2. broken.go (39 bytes)
  3. log.log (3783 bytes)

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