1
0
mirror of https://github.com/golang/go synced 2024-11-11 19:51:37 -07:00

cmd/compile: don't report not enough args error if call is undefined

Fixes #38745

Change-Id: I2fbd8b512a8cf911b81a087162c74416116efea5
Reviewed-on: https://go-review.googlesource.com/c/go/+/253678
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Cuong Manh Le 2020-09-09 16:25:48 +07:00
parent 2c95e3a6a8
commit 806f478499
3 changed files with 3 additions and 4 deletions

View File

@ -2667,7 +2667,7 @@ func typecheckaste(op Op, call *Node, isddd bool, tstruct *types.Type, nl Nodes,
return
notenough:
if n == nil || !n.Diag() {
if n == nil || (!n.Diag() && n.Type != nil) {
details := errorDetails(nl, tstruct, isddd)
if call != nil {
// call is the expression being called, not the overall call.

View File

@ -29,7 +29,7 @@ var (
_ = sum(tuple())
_ = sum(tuple()...) // ERROR "multiple-value"
_ = sum3(tuple())
_ = sum3(tuple()...) // ERROR "multiple-value" "not enough"
_ = sum3(tuple()...) // ERROR "multiple-value"
)
type T []T

View File

@ -14,6 +14,5 @@ func f1() {
}
func f2() (*t, error) {
// BAD: should report undefined error only.
return t{}.M() // ERROR "t{}.M undefined \(type t has no field or method M\)" "not enough arguments to return"
return t{}.M() // ERROR "t{}.M undefined \(type t has no field or method M\)"
}