mirror of
https://github.com/golang/go
synced 2024-11-24 20:30:14 -07:00
ae9c822f78
Show a more specifc error message in the form of "%d variables but %v returns %d values" if an assignment mismatch occurs with a function or method call on the right. Fixes #27595 Change-Id: Ibc97d070662b08f150ac22d686059cf224e012ab Reviewed-on: https://go-review.googlesource.com/135575 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
20 lines
579 B
Go
20 lines
579 B
Go
// errorcheck
|
|
|
|
// Copyright 2018 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.
|
|
|
|
package main
|
|
|
|
var a = twoResults() // ERROR "assignment mismatch: 1 variable but twoResults returns 2 values"
|
|
var b, c, d = twoResults() // ERROR "assignment mismatch: 3 variables but twoResults returns 2 values"
|
|
var e, f = oneResult() // ERROR "assignment mismatch: 2 variables but oneResult returns 1 values"
|
|
|
|
func twoResults() (int, int) {
|
|
return 1, 2
|
|
}
|
|
|
|
func oneResult() int {
|
|
return 1
|
|
}
|