]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: don't report not enough args error if call is undefined
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 9 Sep 2020 09:25:48 +0000 (16:25 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Sat, 12 Sep 2020 08:50:45 +0000 (08:50 +0000)
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>
src/cmd/compile/internal/gc/typecheck.go
test/ddd1.go
test/fixedbugs/issue38745.go

index dec4b96fc4cd8f25b4f8a09ded3c2186c57eec62..fb169cfec840e7c45d754f9f292d10efef91f20d 100644 (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.
index 2c7e83e37452ac9c257b3f5bd8afe6a9866ada81..9857814648ba187090f59a181e4c169bdb36beba 100644 (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
index 21bd1ff3a7cd706dce0d24ec6da96dc00e7a3d71..83a3bc6fad6e0181fa9d3d008695fbf7b0b846fc 100644 (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\)"
 }