Commit 70b09c72 authored by Robert Griesemer's avatar Robert Griesemer

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/96375Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 6450c591
...@@ -53,6 +53,8 @@ Flags controlling additional output: ...@@ -53,6 +53,8 @@ Flags controlling additional output:
print parse trace (forces -seq) print parse trace (forces -seq)
-comments -comments
parse comments (ignored unless -ast or -trace is provided) parse comments (ignored unless -ast or -trace is provided)
-panic
panic on first error
Examples: Examples:
...@@ -105,6 +107,7 @@ var ( ...@@ -105,6 +107,7 @@ var (
printAST = flag.Bool("ast", false, "print AST (forces -seq)") printAST = flag.Bool("ast", false, "print AST (forces -seq)")
printTrace = flag.Bool("trace", false, "print parse trace (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)") parseComments = flag.Bool("comments", false, "parse comments (ignored unless -ast or -trace is provided)")
panicOnError = flag.Bool("panic", false, "panic on first error")
) )
var ( var (
...@@ -164,6 +167,9 @@ func usage() { ...@@ -164,6 +167,9 @@ func usage() {
} }
func report(err error) { func report(err error) {
if *panicOnError {
panic(err)
}
scanner.PrintError(os.Stderr, err) scanner.PrintError(os.Stderr, err)
if list, ok := err.(scanner.ErrorList); ok { if list, ok := err.(scanner.ErrorList); ok {
errorCount += len(list) errorCount += len(list)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment