Commit 3b39f523 authored by Alan Donovan's avatar Alan Donovan

cmd/vet: -lostcancel: fix crash in ill-typed code

Fixes golang/go#19656

Change-Id: Ied20d3f25b6e147cc693a1dd1aeb9480adc6687e
Reviewed-on: https://go-review.googlesource.com/38405Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
parent b029e943
......@@ -104,7 +104,11 @@ func checkLostCancel(f *File, node ast.Node) {
var sig *types.Signature
switch node := node.(type) {
case *ast.FuncDecl:
sig, _ = f.pkg.defs[node.Name].Type().(*types.Signature)
obj := f.pkg.defs[node.Name]
if obj == nil {
return // type error (e.g. duplicate function declaration)
}
sig, _ = obj.Type().(*types.Signature)
g = cfg.New(node.Body, mayReturn)
case *ast.FuncLit:
sig, _ = f.pkg.types[node.Type].Type.(*types.Signature)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment