From a6c151c04db078d856d9bae182646c11f4662a1b Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 25 Sep 2013 10:19:24 -0700 Subject: [PATCH] go.tools/go/types: (panic(0)) (parenthesized) is a terminating statement R=adonovan CC=golang-dev https://golang.org/cl/13913043 --- go/types/return.go | 4 ++-- go/types/testdata/stmt1.src | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go/types/return.go b/go/types/return.go index ad5b22d00cb..fb8ab6dcf3b 100644 --- a/go/types/return.go +++ b/go/types/return.go @@ -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 { diff --git a/go/types/testdata/stmt1.src b/go/types/testdata/stmt1.src index 537c3f4a348..a2955e6fd05 100644 --- a/go/types/testdata/stmt1.src +++ b/go/types/testdata/stmt1.src @@ -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) {