1
0
mirror of https://github.com/golang/go synced 2024-09-30 18:18:32 -06:00

go.tools/go/types, cmd/gotype: fix early bailout

Clients must have chance to look at panics they
are raising.

R=adonovan
CC=golang-dev
https://golang.org/cl/23820043
This commit is contained in:
Robert Griesemer 2013-11-08 12:52:57 -08:00
parent e8fe66cd57
commit 7b183d1766
2 changed files with 6 additions and 10 deletions

View File

@ -196,10 +196,12 @@ func checkPkgFiles(files []*ast.File) {
}
defer func() {
switch err := recover().(type) {
switch p := recover().(type) {
case nil, bailout:
// normal return or early exit
default:
panic(err)
// re-panic
panic(p)
}
}()

View File

@ -7,7 +7,6 @@
package types
import (
"fmt"
"go/ast"
"go/token"
"path"
@ -173,13 +172,8 @@ func (check *checker) handleBailout(err *error) {
// normal return or early exit
*err = check.firstErr
default:
// unexpected panic: don't crash clients
// TODO(gri) add a test case for this scenario
*err = fmt.Errorf("types internal error: %v", p)
if debug {
check.dump("INTERNAL PANIC: %v", p)
panic(p)
}
// re-panic
panic(p)
}
}