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

x/tools/cmd/godoc: panic with the tip version #20641

Closed
YoshikiShibata opened this issue Jun 11, 2017 · 3 comments
Closed

x/tools/cmd/godoc: panic with the tip version #20641

YoshikiShibata opened this issue Jun 11, 2017 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@YoshikiShibata
Copy link

Please answer these questions before submitting your issue. Thanks!

What did you do?

godoc -analysis=type -analysis=pointer -http :8000

What did you expect to see?

No panic

What did you see instead?

2017/06/11 13:31:03 Constructing SSA form...
2017/06/11 13:31:07 SSA construction complete
panic: interface conversion: types.Type is *types.Struct, not *types.Named

goroutine 846 [running]:
golang.org/x/tools/godoc/analysis.Run(0xc4201c0601, 0xc4201a6b30)
	/Users/yoshiki/gocode/src/golang.org/x/tools/godoc/analysis/analysis.go:478 +0x25c4
created by main.main
	/Users/yoshiki/gocode/src/golang.org/x/tools/cmd/godoc/main.go:314 +0xac2

Does this issue reproduce with the latest release (go1.8.3)?

No, because this panic seems to be caused by the introduction of "type alias".

I tried the following modification and it seemed working:

diff --git a/godoc/analysis/analysis.go b/godoc/analysis/analysis.go
index c185e5ea..440e4a80 100644
--- a/godoc/analysis/analysis.go
+++ b/godoc/analysis/analysis.go
@@ -475,7 +475,9 @@ func Run(pta bool, result *Result) {
        for _, info := range iprog.AllPackages {
                for _, obj := range info.Defs {
                        if obj, ok := obj.(*types.TypeName); ok {
-                               a.allNamed = append(a.allNamed, obj.Type().(*types.Named))
+                               if !obj.IsAlias() {
+                                       a.allNamed = append(a.allNamed, obj.Type().(*types.Named))
+                               }
                        }
                }
        }

Anyway, this is not a bug of Go1.8.3, but should be fixed with Go1.9.

System details

go version devel +2c7043c273 Fri Jun 9 22:15:01 2017 +0000 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/yoshiki/gocode:/Users/yoshiki/exercises/gpl:/Users/yoshiki/oak"
GORACE=""
GOROOT="/Users/yoshiki/tools/go"
GOTOOLDIR="/Users/yoshiki/tools/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/pb/c7_4_d355ng5zfm4r_jg2gg00000gn/T/go-build389611353=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOROOT/bin/go version: go version devel +2c7043c273 Fri Jun 9 22:15:01 2017 +0000 darwin/amd64
GOROOT/bin/go tool compile -V: compile version devel +2c7043c273 Fri Jun 9 22:15:01 2017 +0000 X:framepointer
uname -v: Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.12.5
BuildVersion:	16F73
lldb --version: lldb-370.0.42
  Swift-3.1
@gopherbot gopherbot added this to the Unreleased milestone Jun 11, 2017
@odeke-em
Copy link
Member

/cc @griesemer

@bradfitz bradfitz modified the milestones: Go1.9, Unreleased Jun 13, 2017
@bradfitz bradfitz added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 13, 2017
@bradfitz
Copy link
Contributor

Robert, since godoc is part of the release, could you look at this? It's reportedly a regression from 1.8 and related to type aliases.

@alandonovan alandonovan self-assigned this Jun 13, 2017
@gopherbot
Copy link

CL https://golang.org/cl/45570 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants