]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vet: fix a crash in lostcancel check
authorAlan Donovan <adonovan@google.com>
Wed, 22 Jun 2016 14:40:30 +0000 (10:40 -0400)
committerAlan Donovan <adonovan@google.com>
Wed, 22 Jun 2016 16:57:45 +0000 (16:57 +0000)
Fixes issue 16143

Change-Id: Id9d257aee54d31fbf0d478cb07339729cd9712c0
Reviewed-on: https://go-review.googlesource.com/24325
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/vet/lostcancel.go
src/cmd/vet/testdata/lostcancel.go

index 708b6f3029707ec0261c5eae06291296e22780d1..3649e138b9b4f07305fc3857fbbbe26351d0dc98 100644 (file)
@@ -276,7 +276,7 @@ func callName(info *types.Info, call *ast.CallExpr) string {
                        return obj.Name()
                }
        case *ast.SelectorExpr:
-               if sel, ok := info.Selections[fun]; ok {
+               if sel, ok := info.Selections[fun]; ok && sel.Kind() == types.MethodVal {
                        // method call, e.g. "(*testing.common).Fatal"
                        meth := sel.Obj()
                        return fmt.Sprintf("(%s).%s",
index 143456e52fe3f817853fabff69c604a934ba1a7b..213dd1832d45851a1de9fcbbced4473d68990a2d 100644 (file)
@@ -135,3 +135,9 @@ func _() {
 
 var condition bool
 var someInt int
+
+// Regression test for Go issue 16143.
+func _() {
+       var x struct{ f func() }
+       x.f()
+}