Skip to content

go/types: crash in assignment between "unexported" named interface types  #5512

Closed
@remyoudompheng

Description

@remyoudompheng
What steps will reproduce the problem?

Typechekck the follwoing pair of files:

$ cat main.go
package blah

import "testb/pkg"

type stringer interface {
    String() string
}

func F() {
      var t pkg.T
    var s stringer = t.Field
}

$ cat pkg/pkg.go
package pkg

type stringer interface {
    String() string
}

type T struct {
    Field stringer
}

What is the expected output? What do you see instead?

Expected: no error

Instead:
$ gotype .
INTERNAL PANIC: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x10 pc=0x487765]

goroutine 1 [running]:
main.func·002()
    /home/remy/travail/go/src/code.google.com/p/go.tools/gotype/gotype.go:185 +0xa2
code.google.com/p/go.tools/go/types.func·003()
    /home/remy/travail/go/src/code.google.com/p/go.tools/go/types/check.go:447 +0x175
code.google.com/p/go.tools/go/types.identicalMethods(0xc200087820, 0x1, 0x1,
0xc200087850, 0x1, ...)
    /home/remy/travail/go/src/code.google.com/p/go.tools/go/types/predicates.go:219 +0xe5
code.google.com/p/go.tools/go/types.IsIdentical(0xc200079b00, 0xc200064a00,
0xc200079b00, 0xc200064a40, 0x0, ...)
    /home/remy/travail/go/src/code.google.com/p/go.tools/go/types/predicates.go:165 +0x8de
code.google.com/p/go.tools/go/types.(*operand).isAssignable(0xc2000a5cc0, 0xc2000a5480,
0xc200079b40, 0xc2000a2840, 0x0, ...)
    /home/remy/travail/go/src/code.google.com/p/go.tools/go/types/operand.go:144 +0x172
code.google.com/p/go.tools/go/types.(*checker).assignment(0xc20008c0b0, 0xc2000a5cc0,
0xc200079b40, 0xc2000a2840, 0x1, ...)
    /home/remy/travail/go/src/code.google.com/p/go.tools/go/types/stmt.go:36 +0x1dd
code.google.com/p/go.tools/go/types.(*checker).assign1to1(0xc20008c0b0, 0xc2000a5040,
0xc200064660, 0xc2000a52c0, 0xc2000646e0, ...)
    /home/remy/travail/go/src/code.google.com/p/go.tools/go/types/stmt.go:139 +0x563
code.google.com/p/go.tools/go/types.(*checker).valueSpec(0xc20008c0b0, 0x73,
0xc20007d910, 0xc2000a5c40, 0xc200000228, ...)
    /home/remy/travail/go/src/code.google.com/p/go.tools/go/types/check.go:162 +0x3a9
code.google.com/p/go.tools/go/types.(*checker).object(0xc20008c0b0, 0xc20007d910,
0xc2000a5c40, 0xc2000a5c00)
    /home/remy/travail/go/src/code.google.com/p/go.tools/go/types/check.go:247 +0x3ca
code.google.com/p/go.tools/go/types.(*checker).decl(0xc20008c0b0, 0xc200079f80,
0xc2000a53c0)
    /home/remy/travail/go/src/code.google.com/p/go.tools/go/types/check.go:391 +0x44c
code.google.com/p/go.tools/go/types.(*checker).stmt(0xc20008c0b0, 0xc2000a5380,
0xc200087730)
    /home/remy/travail/go/src/code.google.com/p/go.tools/go/types/stmt.go:298 +0x3108
code.google.com/p/go.tools/go/types.(*checker).stmtList(0xc20008c0b0, 0xc200064700, 0x2,
0x2)
    /home/remy/travail/go/src/code.google.com/p/go.tools/go/types/stmt.go:247 +0x68
code.google.com/p/go.tools/go/types.check(0xc2000a5480, 0x5ce2a0, 0x1, 0xc200079e40,
0xc200000240, ...)
    /home/remy/travail/go/src/code.google.com/p/go.tools/go/types/check.go:485 +0x4cf
code.google.com/p/go.tools/go/types.(*Context).Check(0xc2000a5480, 0x5ce2a0, 0x1,
0xc200079e40, 0xc200000240, ...)
    /home/remy/travail/go/src/code.google.com/p/go.tools/go/types/api.go:112 +0x6c
main.processPackage(0xc200079e40, 0xc200000240, 0x1, 0x1)
    /home/remy/travail/go/src/code.google.com/p/go.tools/gotype/gotype.go:189 +0xd9
main.processFiles(0xc200086700, 0x2, 0x64, 0xc200000100)
    /home/remy/travail/go/src/code.google.com/p/go.tools/gotype/gotype.go:167 +0x178
main.processDirectory(0x7fff7b5d0923, 0x1)
    /home/remy/travail/go/src/code.google.com/p/go.tools/gotype/gotype.go:146 +0x24a
main.processFiles(0xc200064010, 0x1, 0x1, 0x417301)
    /home/remy/travail/go/src/code.google.com/p/go.tools/gotype/gotype.go:157 +0x1d9
main.main()
    /home/remy/travail/go/src/code.google.com/p/go.tools/gotype/gotype.go:200 +0xea

goroutine 2 [runnable]:


Please use labels and text to provide additional information.

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