Skip to content

Commit

Permalink
cmd/guru: fix incorrect case order in describe.go
Browse files Browse the repository at this point in the history
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 <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Alan Donovan <[email protected]>
  • Loading branch information
quasilyte authored and bradfitz committed Jan 2, 2019
1 parent 52ae6de commit ca9055e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/guru/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit ca9055e

Please sign in to comment.