Black Lives Matter. Support the Equal Justice Initiative.

Text file src/go/types/testdata/check/stmt1.src

Documentation: go/types/testdata/check

     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  		return; ; ; // trailing empty statements are ok
    26  	}
    27  	; ; ;
    28  }
    29  
    30  func _(x, y int) (z int) {
    31  	{
    32  	}
    33  } /* ERROR "missing return" */
    34  
    35  func _(x, y int) (z int) {
    36  	{
    37  		; ; ;
    38  	}
    39  	; ; ;
    40  } /* ERROR "missing return" */
    41  
    42  // if statements
    43  func _(x, y int) (z int) {
    44  	if x < y { return }
    45  	return 1
    46  }
    47  
    48  func _(x, y int) (z int) {
    49  	if x < y { return; ; ; ; }
    50  	return 1
    51  }
    52  
    53  func _(x, y int) (z int) {
    54  	if x < y { return }
    55  	return 1; ;
    56  }
    57  
    58  func _(x, y int) (z int) {
    59  	if x < y { return }
    60  } /* ERROR "missing return" */
    61  
    62  func _(x, y int) (z int) {
    63  	if x < y {
    64  	} else { return 1
    65  	}
    66  } /* ERROR "missing return" */
    67  
    68  func _(x, y int) (z int) {
    69  	if x < y { return
    70  	} else { return
    71  	}
    72  }
    73  
    74  // for statements
    75  func _(x, y int) (z int) {
    76  	for x < y {
    77  		return
    78  	}
    79  } /* ERROR "missing return" */
    80  
    81  func _(x, y int) (z int) {
    82  	for {
    83  		return
    84  	}
    85  }
    86  
    87  func _(x, y int) (z int) {
    88  	for {
    89  		return; ; ; ;
    90  	}
    91  }
    92  
    93  func _(x, y int) (z int) {
    94  	for {
    95  		return
    96  		break
    97  	}
    98  	; ; ;
    99  } /* ERROR "missing return" */
   100  
   101  func _(x, y int) (z int) {
   102  	for {
   103  		for { break }
   104  		return
   105  	}
   106  }
   107  
   108  func _(x, y int) (z int) {
   109  	for {
   110  		for { break }
   111  		return ; ;
   112  	}
   113  	;
   114  }
   115  
   116  func _(x, y int) (z int) {
   117  L:	for {
   118  		for { break L }
   119  		return
   120  	}
   121  } /* ERROR "missing return" */
   122  
   123  // switch statements
   124  func _(x, y int) (z int) {
   125  	switch x {
   126  	case 0: return
   127  	default: return
   128  	}
   129  }
   130  
   131  func _(x, y int) (z int) {
   132  	switch x {
   133  	case 0: return;
   134  	default: return; ; ;
   135  	}
   136  }
   137  
   138  func _(x, y int) (z int) {
   139  	switch x {
   140  	case 0: return
   141  	}
   142  } /* ERROR "missing return" */
   143  
   144  func _(x, y int) (z int) {
   145  	switch x {
   146  	case 0: return
   147  	case 1: break
   148  	}
   149  } /* ERROR "missing return" */
   150  
   151  func _(x, y int) (z int) {
   152  	switch x {
   153  	case 0: return
   154  	default:
   155  		switch y {
   156  		case 0: break
   157  		}
   158  		panic(0)
   159  	}
   160  }
   161  
   162  func _(x, y int) (z int) {
   163  	switch x {
   164  	case 0: return
   165  	default:
   166  		switch y {
   167  		case 0: break
   168  		}
   169  		panic(0); ; ;
   170  	}
   171  	;
   172  }
   173  
   174  func _(x, y int) (z int) {
   175  L:	switch x {
   176  	case 0: return
   177  	default:
   178  		switch y {
   179  		case 0: break L
   180  		}
   181  		panic(0)
   182  	}
   183  } /* ERROR "missing return" */
   184  
   185  // select statements
   186  func _(ch chan int) (z int) {
   187  	select {}
   188  } // nice!
   189  
   190  func _(ch chan int) (z int) {
   191  	select {}
   192  	; ;
   193  }
   194  
   195  func _(ch chan int) (z int) {
   196  	select {
   197  	default: break
   198  	}
   199  } /* ERROR "missing return" */
   200  
   201  func _(ch chan int) (z int) {
   202  	select {
   203  	case <-ch: return
   204  	default: break
   205  	}
   206  } /* ERROR "missing return" */
   207  
   208  func _(ch chan int) (z int) {
   209  	select {
   210  	case <-ch: return
   211  	default:
   212  		for i := 0; i < 10; i++ {
   213  			break
   214  		}
   215  		return
   216  	}
   217  }
   218  
   219  func _(ch chan int) (z int) {
   220  	select {
   221  	case <-ch: return; ; ;
   222  	default:
   223  		for i := 0; i < 10; i++ {
   224  			break
   225  		}
   226  		return; ; ;
   227  	}
   228  	; ; ;
   229  }
   230  
   231  func _(ch chan int) (z int) {
   232  L:	select {
   233  	case <-ch: return
   234  	default:
   235  		for i := 0; i < 10; i++ {
   236  			break L
   237  		}
   238  		return
   239  	}
   240  	; ; ;
   241  } /* ERROR "missing return" */
   242  
   243  func parenPanic() int {
   244  	((((((panic)))(0))))
   245  }
   246  
   247  func issue23218a() int {
   248  	{
   249  		panic := func(interface{}){}
   250  		panic(0)
   251  	}
   252  } /* ERROR "missing return" */
   253  
   254  func issue23218b() int {
   255  	{
   256  		panic := func(interface{}){}
   257  		((((panic))))(0)
   258  	}
   259  } /* ERROR "missing return" */
   260  

View as plain text