reject_missing_return.mx raw

   1  // expected: missing return
   2  //
   3  // A function with results must end in a terminating statement. go/types
   4  // rejects the body below on the legacy side; stage4 compiled it and returned
   5  // the zero value, so a forgotten return path was accepted on one side only.
   6  // The rules are the Go spec's terminating statements, the same ones go/types
   7  // applies in return.go.
   8  package main
   9  
  10  func f() (r int32) {
  11  	if false {
  12  		return 1
  13  	}
  14  }
  15  
  16  func main() {
  17  	println(f())
  18  }
  19