1
0
mirror of https://github.com/golang/go synced 2024-11-05 20:16:13 -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: case *ast.ValueSpec:
// TODO(adonovan): ValueSpec.{Doc,Comment}? // TODO(adonovan): ValueSpec.{Doc,Comment}?
default: case *ast.BadDecl, *ast.BadExpr, *ast.BadStmt:
// Includes *ast.BadDecl, *ast.BadExpr, *ast.BadStmt. // nop
panic(fmt.Sprintf("unexpected node type %T", n))
} }
// TODO(adonovan): opt: merge the logic of ast.Inspect() into // TODO(adonovan): opt: merge the logic of ast.Inspect() into