1
0
mirror of https://github.com/golang/go synced 2024-11-23 20:10:08 -07:00

go/doc: don't panic if method is missing recv type

Fixes #17788

Change-Id: I2f8a11321dc8f10bebbc8df90ba00ec65b9ee0fa
Reviewed-on: https://go-review.googlesource.com/32790
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Keegan Carruthers-Smith 2016-11-04 09:31:35 +02:00 committed by Russ Cox
parent 9a5bddd7ed
commit 50fed64dd9
5 changed files with 37 additions and 0 deletions

View File

@ -362,6 +362,11 @@ func (r *reader) readFunc(fun *ast.FuncDecl) {
// associate methods with the receiver type, if any
if fun.Recv != nil {
// method
if len(fun.Recv.List) == 0 {
// should not happen (incorrect AST); (See issue 17788)
// don't show this method
return
}
recvTypeName, imp := baseTypeName(fun.Recv.List[0].Type)
if imp {
// should not happen (incorrect AST);

View File

@ -0,0 +1,8 @@
//
PACKAGE issue17788
IMPORTPATH
testdata/issue17788
FILENAMES
testdata/issue17788.go

View File

@ -0,0 +1,8 @@
//
PACKAGE issue17788
IMPORTPATH
testdata/issue17788
FILENAMES
testdata/issue17788.go

View File

@ -0,0 +1,8 @@
//
PACKAGE issue17788
IMPORTPATH
testdata/issue17788
FILENAMES
testdata/issue17788.go

8
src/go/doc/testdata/issue17788.go vendored Normal file
View File

@ -0,0 +1,8 @@
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package issue17788
func ( /* receiver type */ ) f0() {
}