aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/typecheck.go
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2021-05-03 02:19:10 +0700
committerCuong Manh Le <cuong.manhle.vn@gmail.com>2021-05-03 15:03:57 +0000
commit844e1fc6f1d0dacd92534dba7f8d71f377017742 (patch)
treee1d023794320439a18c34487814a38731f2724c3 /src/cmd/compile/internal/typecheck/typecheck.go
parent9ed736ac2a99aa2e7ef7d8bed3b01ca8b20a6f80 (diff)
downloadgo-844e1fc6f1d0dacd92534dba7f8d71f377017742.tar.gz
go-844e1fc6f1d0dacd92534dba7f8d71f377017742.zip
cmd/compile: make typecheckaste correctly report invalid use of "..."
Currently, when "..." argument is passed to non-variadic function, the compiler may skip that check, but continue checking whether the number of arguments matches the function signature. That causes the sanity check which was added in CL 255241 trigger. Instead, we should report an invalid use of "...", which matches the behavior of new type checker and go/types. Fixes #45913 Change-Id: Icbb254052cbcd756bbd41f966c2c8e316c44420f Reviewed-on: https://go-review.googlesource.com/c/go/+/315796 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/typecheck.go')
-rw-r--r--src/cmd/compile/internal/typecheck/typecheck.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go
index 1650144375..4c5472137a 100644
--- a/src/cmd/compile/internal/typecheck/typecheck.go
+++ b/src/cmd/compile/internal/typecheck/typecheck.go
@@ -1330,6 +1330,9 @@ func typecheckaste(op ir.Op, call ir.Node, isddd bool, tstruct *types.Type, nl i
n1 := tstruct.NumFields()
n2 := len(nl)
if !hasddd(tstruct) {
+ if isddd {
+ goto invalidddd
+ }
if n2 > n1 {
goto toomany
}
@@ -1395,6 +1398,8 @@ func typecheckaste(op ir.Op, call ir.Node, isddd bool, tstruct *types.Type, nl i
if i < len(nl) {
goto toomany
}
+
+invalidddd:
if isddd {
if call != nil {
base.Errorf("invalid use of ... in call to %v", call)