1
0
mirror of https://github.com/golang/go synced 2024-11-05 17:46:16 -07:00

cmd/guru: don't panic on *ast.Bad{Decl,Stmt,Expr}

These nodes are common in incomplete programs.

Change-Id: Iff9750050c78762f0cb8bebc7739584c197d661e
Reviewed-on: https://go-review.googlesource.com/19509
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
Alan Donovan 2016-02-15 15:48:08 -05:00 committed by Alan Donovan
parent d7762ee5c0
commit cadb821a95

View File

@ -447,9 +447,8 @@ func childrenOf(n ast.Node) []ast.Node {
case *ast.ValueSpec:
// TODO(adonovan): ValueSpec.{Doc,Comment}?
default:
// Includes *ast.BadDecl, *ast.BadExpr, *ast.BadStmt.
panic(fmt.Sprintf("unexpected node type %T", n))
case *ast.BadDecl, *ast.BadExpr, *ast.BadStmt:
// nop
}
// TODO(adonovan): opt: merge the logic of ast.Inspect() into