1
0
mirror of https://github.com/golang/go synced 2024-11-27 05:01:19 -07:00
go/test/fixedbugs/issue19012.go
Robert Griesemer 91a40f43b6 go/types, types2: don't report assignment mismatch errors if there are other errors
Change the Checker.use/useLHS functions to report if all "used"
expressions evaluated without error. Use that information to
control whether to report an assignment mismatch error or not.
This will reduce the number of errors reported per assignment,
where the assignment mismatch is only one of the errors.

Change-Id: Ia0fc3203253b002e4e1d5759d8d5644999af6884
Reviewed-on: https://go-review.googlesource.com/c/go/+/478756
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-03-28 22:22:08 +00:00

26 lines
872 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 with value in function with no return|no result values expected|mismatched types"
}
return "gopher" == true, 10 // ERROR "^too many arguments to return$|return with value in function with no return|no result values expected|mismatched types"
}
func main() {
f(2, 3 < "x", 10) // ERROR "too many arguments|invalid operation|incompatible type"
f(10, 10, "a") // ERROR "too many arguments"
}