From: Robert Griesemer Date: Thu, 10 Dec 2020 19:30:18 +0000 (-0800) Subject: [dev.typeparams] cmd/compile/internal/types2: report invalid ... in conversions X-Git-Tag: go1.17beta1~1473^2~158 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f8930a241301b9922beef925e4ca685f8c3e95a7;p=gostls13.git [dev.typeparams] cmd/compile/internal/types2: report invalid ... in conversions This fixes the bug below for types2. Updates #43124. Change-Id: Ic1962d41f321d8a08992d8529625bc133e526b0c Reviewed-on: https://go-review.googlesource.com/c/go/+/278012 Trust: Robert Griesemer Run-TryBot: Robert Griesemer Reviewed-by: Robert Findley TryBot-Result: Go Bot --- diff --git a/src/cmd/compile/internal/types2/call.go b/src/cmd/compile/internal/types2/call.go index fe3c17fc6b..5ecd54ab0b 100644 --- a/src/cmd/compile/internal/types2/call.go +++ b/src/cmd/compile/internal/types2/call.go @@ -128,6 +128,10 @@ func (check *Checker) call(x *operand, call *syntax.CallExpr) exprKind { break } } + if call.HasDots { + check.errorf(call.ArgList[0], "invalid use of ... in type conversion to %s)", T) + break + } check.conversion(x, T) } default: diff --git a/src/cmd/compile/internal/types2/fixedbugs/issue43124.src b/src/cmd/compile/internal/types2/fixedbugs/issue43124.src new file mode 100644 index 0000000000..7e48c2211b --- /dev/null +++ b/src/cmd/compile/internal/types2/fixedbugs/issue43124.src @@ -0,0 +1,16 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +var _ = int(0 /* ERROR invalid use of \.\.\. in type conversion */ ...) + +// test case from issue + +type M []string + +var ( + x = []string{"a", "b"} + _ = M(x /* ERROR invalid use of \.\.\. in type conversion */ ...) +)