1
0
mirror of https://github.com/golang/go synced 2024-11-08 18:26:14 -07:00
go/test/fixedbugs/issue19012.go
Emmanuel Odeke 19d2061d50 cmd/compile: suppress callsite signatures if any type is unknown
Fixes #19012.

Fallback to return signatures without detailed types.
These error message will be of the form of issue:
* https://golang.org/issues/4215
* https://golang.org/issues/6750

So:
func f(x int, y uint) {
    return x > y
}

f(10, "a" < 3)

will give errors:
too many errors to return
too many arguments in call to f

instead of:

too many errors to return
  have (<T>)
  want ()
too many arguments in call to f
  have (number, <T>)
  want (number, number)

Change-Id: I680abc7cdd8444400e234caddf3ff49c2d69f53d
Reviewed-on: https://go-review.googlesource.com/36806
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-02-22 17:55:45 +00:00

26 lines
757 B
Go

// errorcheck
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Issue 19012: if we have any unknown type at a call site,
// we must ensure that we return to the user a suppressed
// error message saying instead of including <T> in
// the message.
package main
func f(x int, y uint) {
if true {
return "a" > 10 // ERROR "^too many arguments to return$" "."
}
return "gopher" == true, 10 // ERROR "^too many arguments to return$" "."
}
func main() {
f(2, 3 < "x", 10) // ERROR "^too many arguments in call to f$" "."
f(10, 10, "a") // ERROR "too many arguments in call to f\n\thave \(number, number, string\)\n\twant \(int, uint\)"
}