github.com/miolini/go@v0.0.0-20160405192216-fca68c8cb408/src/go/types/testdata/stmt1.src (about)

     1  // Copyright 2013 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // terminating statements
     6  
     7  package stmt1
     8  
     9  func _() {}
    10  
    11  func _() int {} /* ERROR "missing return" */
    12  
    13  func _() int { panic(0) }
    14  func _() int { (panic(0)) }
    15  
    16  // block statements
    17  func _(x, y int) (z int) {
    18  	{
    19  		return
    20  	}
    21  }
    22  
    23  func _(x, y int) (z int) {
    24  	{
    25  	}
    26  } /* ERROR "missing return" */
    27  
    28  // if statements
    29  func _(x, y int) (z int) {
    30  	if x < y { return }
    31  	return 1
    32  }
    33  
    34  func _(x, y int) (z int) {
    35  	if x < y { return }
    36  } /* ERROR "missing return" */
    37  
    38  func _(x, y int) (z int) {
    39  	if x < y {
    40  	} else { return 1
    41  	}
    42  } /* ERROR "missing return" */
    43  
    44  func _(x, y int) (z int) {
    45  	if x < y { return
    46  	} else { return
    47  	}
    48  }
    49  
    50  // for statements
    51  func _(x, y int) (z int) {
    52  	for x < y {
    53  		return
    54  	}
    55  } /* ERROR "missing return" */
    56  
    57  func _(x, y int) (z int) {
    58  	for {
    59  		return
    60  	}
    61  }
    62  
    63  func _(x, y int) (z int) {
    64  	for {
    65  		return
    66  		break
    67  	}
    68  } /* ERROR "missing return" */
    69  
    70  func _(x, y int) (z int) {
    71  	for {
    72  		for { break }
    73  		return
    74  	}
    75  }
    76  
    77  func _(x, y int) (z int) {
    78  L:	for {
    79  		for { break L }
    80  		return
    81  	}
    82  } /* ERROR "missing return" */
    83  
    84  // switch statements
    85  func _(x, y int) (z int) {
    86  	switch x {
    87  	case 0: return
    88  	default: return
    89  	}
    90  }
    91  
    92  func _(x, y int) (z int) {
    93  	switch x {
    94  	case 0: return
    95  	}
    96  } /* ERROR "missing return" */
    97  
    98  func _(x, y int) (z int) {
    99  	switch x {
   100  	case 0: return
   101  	case 1: break
   102  	}
   103  } /* ERROR "missing return" */
   104  
   105  func _(x, y int) (z int) {
   106  	switch x {
   107  	case 0: return
   108  	default:
   109  		switch y {
   110  		case 0: break
   111  		}
   112  		panic(0)
   113  	}
   114  }
   115  
   116  func _(x, y int) (z int) {
   117  L:	switch x {
   118  	case 0: return
   119  	default:
   120  		switch y {
   121  		case 0: break L
   122  		}
   123  		panic(0)
   124  	}
   125  } /* ERROR "missing return" */
   126  
   127  // select statements
   128  func _(ch chan int) (z int) {
   129  	select {}
   130  } // nice!
   131  
   132  func _(ch chan int) (z int) {
   133  	select {
   134  	default: break
   135  	}
   136  } /* ERROR "missing return" */
   137  
   138  func _(ch chan int) (z int) {
   139  	select {
   140  	case <-ch: return
   141  	default: break
   142  	}
   143  } /* ERROR "missing return" */
   144  
   145  func _(ch chan int) (z int) {
   146  	select {
   147  	case <-ch: return
   148  	default:
   149  		for i := 0; i < 10; i++ {
   150  			break
   151  		}
   152  		return
   153  	}
   154  }
   155  
   156  func _(ch chan int) (z int) {
   157  L:	select {
   158  	case <-ch: return
   159  	default:
   160  		for i := 0; i < 10; i++ {
   161  			break L
   162  		}
   163  		return
   164  	}
   165  } /* ERROR "missing return" */