1
0
mirror of https://github.com/golang/go synced 2024-11-18 19:14:40 -07:00

go.tools/go/types: (panic(0)) (parenthesized) is a terminating statement

R=adonovan
CC=golang-dev
https://golang.org/cl/13913043
This commit is contained in:
Robert Griesemer 2013-09-25 10:19:24 -07:00
parent 9d1c551b43
commit a6c151c04d
2 changed files with 3 additions and 2 deletions

View File

@ -28,8 +28,8 @@ func (check *checker) isTerminating(s ast.Stmt, label string) bool {
return check.isTerminating(s.Stmt, s.Label.Name)
case *ast.ExprStmt:
// the predeclared panic() function is terminating
if call, _ := s.X.(*ast.CallExpr); call != nil {
// the predeclared (possibly parenthesized) panic() function is terminating
if call, _ := unparen(s.X).(*ast.CallExpr); call != nil {
if id, _ := call.Fun.(*ast.Ident); id != nil {
if obj := check.topScope.LookupParent(id.Name); obj != nil {
if b, _ := obj.(*Builtin); b != nil && b.id == _Panic {

View File

@ -11,6 +11,7 @@ func _() {}
func _() int {} /* ERROR "missing return" */
func _() int { panic(0) }
func _() int { (panic(0)) }
// block statements
func _(x, y int) (z int) {