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:
parent
9d1c551b43
commit
a6c151c04d
@ -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 {
|
||||
|
1
go/types/testdata/stmt1.src
vendored
1
go/types/testdata/stmt1.src
vendored
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user