mirror of
https://github.com/golang/go
synced 2024-11-18 14:04:45 -07: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:
parent
e8fe66cd57
commit
7b183d1766
@ -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)
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/token"
|
||||
"path"
|
||||
@ -173,15 +172,10 @@ 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)
|
||||
// re-panic
|
||||
panic(p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (conf *Config) check(pkgPath string, fset *token.FileSet, files []*ast.File, info *Info) (pkg *Package, err error) {
|
||||
// make sure we have a package canonicalization map
|
||||
|
Loading…
Reference in New Issue
Block a user