From ca9055ed7d0470e61b81778f76637846e891ff60 Mon Sep 17 00:00:00 2001 From: Iskander Sharipov Date: Mon, 10 Dec 2018 13:41:58 +0300 Subject: [PATCH] cmd/guru: fix incorrect case order in describe.go Since *ast.CommClause implements ast.Stmt, type switch for it would never execute in the original code, it will always execute ast.Stmt branch. Moving concrete types before interfaces help in this case. Change-Id: Id84f2f7f3fac859029155d8e6debf4a8ef170b26 Reviewed-on: https://go-review.googlesource.com/c/153397 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Alan Donovan --- cmd/guru/describe.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/guru/describe.go b/cmd/guru/describe.go index 49a096b4..125e4097 100644 --- a/cmd/guru/describe.go +++ b/cmd/guru/describe.go @@ -162,6 +162,9 @@ func findInterestingNode(pkginfo *loader.PackageInfo, path []ast.Node) ([]ast.No path = append([]ast.Node{n.Name}, path...) continue + case *ast.Comment, *ast.CommentGroup, *ast.File, *ast.KeyValueExpr, *ast.CommClause: + return path, actionUnknown // uninteresting + case ast.Stmt: return path, actionStmt @@ -173,9 +176,6 @@ func findInterestingNode(pkginfo *loader.PackageInfo, path []ast.Node) ([]ast.No *ast.ChanType: return path, actionType - case *ast.Comment, *ast.CommentGroup, *ast.File, *ast.KeyValueExpr, *ast.CommClause: - return path, actionUnknown // uninteresting - case *ast.Ellipsis: // Continue to enclosing node. // e.g. [...]T in ArrayType