From 70b09c72716798caa1b8b55baabdb6a10e275472 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 22 Feb 2018 10:15:42 -0800 Subject: [PATCH] go/types: add -panic flag to gotype command for debugging Setting -panic will cause gotype to panic with the first reported error, producing a stack trace for debugging. For #23914. Change-Id: I40c41cf10aa13d1dd9a099f727ef4201802de13a Reviewed-on: https://go-review.googlesource.com/96375 Reviewed-by: Brad Fitzpatrick --- src/go/types/gotype.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/go/types/gotype.go b/src/go/types/gotype.go index 2efb4c0ac9..cde373f355 100644 --- a/src/go/types/gotype.go +++ b/src/go/types/gotype.go @@ -53,6 +53,8 @@ Flags controlling additional output: print parse trace (forces -seq) -comments parse comments (ignored unless -ast or -trace is provided) + -panic + panic on first error Examples: @@ -105,6 +107,7 @@ var ( printAST = flag.Bool("ast", false, "print AST (forces -seq)") printTrace = flag.Bool("trace", false, "print parse trace (forces -seq)") parseComments = flag.Bool("comments", false, "parse comments (ignored unless -ast or -trace is provided)") + panicOnError = flag.Bool("panic", false, "panic on first error") ) var ( @@ -164,6 +167,9 @@ func usage() { } func report(err error) { + if *panicOnError { + panic(err) + } scanner.PrintError(os.Stderr, err) if list, ok := err.(scanner.ErrorList); ok { errorCount += len(list)