Skip to content

Commit 806f478

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent 2c95e3a commit 806f478

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

src/cmd/compile/internal/gc/typecheck.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2667,7 +2667,7 @@ func typecheckaste(op Op, call *Node, isddd bool, tstruct *types.Type, nl Nodes,
26672667
return
26682668

26692669
notenough:
2670-
if n == nil || !n.Diag() {
2670+
if n == nil || (!n.Diag() && n.Type != nil) {
26712671
details := errorDetails(nl, tstruct, isddd)
26722672
if call != nil {
26732673
// call is the expression being called, not the overall call.

test/ddd1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var (
2929
_ = sum(tuple())
3030
_ = sum(tuple()...) // ERROR "multiple-value"
3131
_ = sum3(tuple())
32-
_ = sum3(tuple()...) // ERROR "multiple-value" "not enough"
32+
_ = sum3(tuple()...) // ERROR "multiple-value"
3333
)
3434

3535
type T []T

test/fixedbugs/issue38745.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ func f1() {
1414
}
1515

1616
func f2() (*t, error) {
17-
// BAD: should report undefined error only.
18-
return t{}.M() // ERROR "t{}.M undefined \(type t has no field or method M\)" "not enough arguments to return"
17+
return t{}.M() // ERROR "t{}.M undefined \(type t has no field or method M\)"
1918
}

0 commit comments

Comments
 (0)