}
func (check *Checker) isTerminatingList(list []ast.Stmt, label string) bool {
- n := len(list)
- return n > 0 && check.isTerminating(list[n-1], label)
+ // trailing empty statements are permitted - skip them
+ for i := len(list) - 1; i >= 0; i-- {
+ if _, ok := list[i].(*ast.EmptyStmt); !ok {
+ return check.isTerminating(list[i], label)
+ }
+ }
+ return false // all statements are empty
}
func (check *Checker) isTerminatingSwitch(body *ast.BlockStmt, label string) bool {
}
}
+func _(x, y int) (z int) {
+ {
+ return; ; ; // trailing empty statements are ok
+ }
+ ; ; ;
+}
+
func _(x, y int) (z int) {
{
}
} /* ERROR "missing return" */
+func _(x, y int) (z int) {
+ {
+ ; ; ;
+ }
+ ; ; ;
+} /* ERROR "missing return" */
+
// if statements
func _(x, y int) (z int) {
if x < y { return }
return 1
}
+func _(x, y int) (z int) {
+ if x < y { return; ; ; ; }
+ return 1
+}
+
+func _(x, y int) (z int) {
+ if x < y { return }
+ return 1; ;
+}
+
func _(x, y int) (z int) {
if x < y { return }
} /* ERROR "missing return" */
}
}
+func _(x, y int) (z int) {
+ for {
+ return; ; ; ;
+ }
+}
+
func _(x, y int) (z int) {
for {
return
break
}
+ ; ; ;
} /* ERROR "missing return" */
func _(x, y int) (z int) {
}
}
+func _(x, y int) (z int) {
+ for {
+ for { break }
+ return ; ;
+ }
+ ;
+}
+
func _(x, y int) (z int) {
L: for {
for { break L }
}
}
+func _(x, y int) (z int) {
+ switch x {
+ case 0: return;
+ default: return; ; ;
+ }
+}
+
func _(x, y int) (z int) {
switch x {
case 0: return
}
}
+func _(x, y int) (z int) {
+ switch x {
+ case 0: return
+ default:
+ switch y {
+ case 0: break
+ }
+ panic(0); ; ;
+ }
+ ;
+}
+
func _(x, y int) (z int) {
L: switch x {
case 0: return
select {}
} // nice!
+func _(ch chan int) (z int) {
+ select {}
+ ; ;
+}
+
func _(ch chan int) (z int) {
select {
default: break
}
}
+func _(ch chan int) (z int) {
+ select {
+ case <-ch: return; ; ;
+ default:
+ for i := 0; i < 10; i++ {
+ break
+ }
+ return; ; ;
+ }
+ ; ; ;
+}
+
func _(ch chan int) (z int) {
L: select {
case <-ch: return
}
return
}
+ ; ; ;
} /* ERROR "missing return" */