mirror of https://github.com/golang/go.git
go/doc: avoid panic on reference to external function
This change guards a call to ast.Inspect with a nil check on the first argument. This avoids a panic when inspecting a reference to a function with an external body. Fixes #42706
This commit is contained in:
parent
d76060814e
commit
08072b9ce5
|
|
@ -237,7 +237,10 @@ func playExample(file *ast.File, f *ast.FuncDecl) *ast.File {
|
|||
}
|
||||
}
|
||||
|
||||
// Functions might not have a body. See #42706.
|
||||
if d.Body != nil {
|
||||
ast.Inspect(d.Body, inspectFunc)
|
||||
}
|
||||
case *ast.GenDecl:
|
||||
for _, spec := range d.Specs {
|
||||
switch s := spec.(type) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue