diff options
| author | Robert Griesemer <gri@golang.org> | 2024-11-27 11:36:53 -0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-11-27 20:50:39 +0000 |
| commit | bcb934ad11060b4ed45663cf6e25bd7b7e92c1bb (patch) | |
| tree | 7ec069398b37424bf0f756bf27b2ae146460fc76 /src/internal | |
| parent | 91d7ab2cefcc653f8b438fbfaa48d504dbfa4f00 (diff) | |
| download | go-bcb934ad11060b4ed45663cf6e25bd7b7e92c1bb.tar.xz | |
go/types, types2: fix printing of error message with variadic calls
Distinguish between variadic signatures and argument lists to
(possibly variadic) functions and place `...` before or after
the last type in the list of types.
Fixes a panic.
Fixes #70526.
Change-Id: I77aba8f50984a21ebcdb62582030f2d0fe0eb097
Reviewed-on: https://go-review.googlesource.com/c/go/+/632275
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/internal')
| -rw-r--r-- | src/internal/types/testdata/fixedbugs/issue70150.go | 4 | ||||
| -rw-r--r-- | src/internal/types/testdata/fixedbugs/issue70526.go | 13 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/internal/types/testdata/fixedbugs/issue70150.go b/src/internal/types/testdata/fixedbugs/issue70150.go index ea308cfddb..5baf4a6630 100644 --- a/src/internal/types/testdata/fixedbugs/issue70150.go +++ b/src/internal/types/testdata/fixedbugs/issue70150.go @@ -7,8 +7,8 @@ package p func _() { var values []int vf(values /* ERROR "(variable of type []int) as string value" */) - vf(values...) /* ERROR "have (...int)" */ - vf("ab", "cd", values /* ERROR "have (string, string, ...int)" */ ...) + vf(values...) /* ERROR "have ([]int...)\n\twant (string, ...int)" */ + vf("ab", "cd", values /* ERROR "have (string, string, []int...)\n\twant (string, ...int)" */ ...) } func vf(method string, values ...int) { diff --git a/src/internal/types/testdata/fixedbugs/issue70526.go b/src/internal/types/testdata/fixedbugs/issue70526.go new file mode 100644 index 0000000000..56b20bfc3c --- /dev/null +++ b/src/internal/types/testdata/fixedbugs/issue70526.go @@ -0,0 +1,13 @@ +// Copyright 2024 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 + +func f(...any) + +func _(x int, s []int) { + f(0, x /* ERROR "have (number, int...)\n\twant (...any)" */ ...) + f(0, s /* ERROR "have (number, []int...)\n\twant (...any)" */ ...) + f(0, 0 /* ERROR "have (number, number...)\n\twant (...any)" */ ...) +} |
