reject_undefined_param_type.mx raw

   1  // expected: undefined: Undefined
   2  //
   3  // A BARE undefined parameter type, in the non-variadic form. This is the leak
   4  // measured in round 85: the source built with rc=0 and only failed at run time
   5  // (the call returned an empty string, so `s != "7"` panicked), because the
   6  // checker left the parameter type nil and nothing reported the name.
   7  //
   8  // The qualified form of the same leak is pinned by reject_unimported_param_type.
   9  // The bare form is reported only for a declaration that cannot have type
  10  // parameters of its own - a non-generic top-level function - because an unbound
  11  // type parameter looks exactly like this to the resolver, and methods are
  12  // excluded for the same reason (a generic receiver's type params are not in
  13  // scope when its signature is resolved).
  14  package main
  15  
  16  func f(x Undefined) (s string) {
  17  	return x.String()
  18  }
  19  
  20  func main() {
  21  	s := f(int32(7))
  22  	if s != "7" {
  23  		panic(s)
  24  	}
  25  }
  26