mirror of
https://github.com/golang/go
synced 2024-11-22 23:50:03 -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:
parent
2c95e3a6a8
commit
806f478499
@ -2667,7 +2667,7 @@ func typecheckaste(op Op, call *Node, isddd bool, tstruct *types.Type, nl Nodes,
|
|||||||
return
|
return
|
||||||
|
|
||||||
notenough:
|
notenough:
|
||||||
if n == nil || !n.Diag() {
|
if n == nil || (!n.Diag() && n.Type != nil) {
|
||||||
details := errorDetails(nl, tstruct, isddd)
|
details := errorDetails(nl, tstruct, isddd)
|
||||||
if call != nil {
|
if call != nil {
|
||||||
// call is the expression being called, not the overall call.
|
// call is the expression being called, not the overall call.
|
||||||
|
@ -29,7 +29,7 @@ var (
|
|||||||
_ = sum(tuple())
|
_ = sum(tuple())
|
||||||
_ = sum(tuple()...) // ERROR "multiple-value"
|
_ = sum(tuple()...) // ERROR "multiple-value"
|
||||||
_ = sum3(tuple())
|
_ = sum3(tuple())
|
||||||
_ = sum3(tuple()...) // ERROR "multiple-value" "not enough"
|
_ = sum3(tuple()...) // ERROR "multiple-value"
|
||||||
)
|
)
|
||||||
|
|
||||||
type T []T
|
type T []T
|
||||||
|
@ -14,6 +14,5 @@ func f1() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func f2() (*t, error) {
|
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\)"
|
||||||
return t{}.M() // ERROR "t{}.M undefined \(type t has no field or method M\)" "not enough arguments to return"
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user