Skip to content

Commit 3b5188e

Browse files
griesemergopherbot
authored andcommitted
go/types, types2: use "multiple-value" instead "n-valued" in error messages
This matches current compiler behavior. For #55326. Change-Id: I9ebe2914323072b5454fb9af2d15c9dd2d711bad Reviewed-on: https://go-review.googlesource.com/c/go/+/434735 Run-TryBot: Robert Griesemer <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Robert Griesemer <[email protected]>
1 parent 605148c commit 3b5188e

File tree

9 files changed

+23
-31
lines changed

9 files changed

+23
-31
lines changed

src/cmd/compile/internal/types2/expr.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,11 +1860,7 @@ func (check *Checker) singleValue(x *operand) {
18601860
// tuple types are never named - no need for underlying type below
18611861
if t, ok := x.typ.(*Tuple); ok {
18621862
assert(t.Len() != 1)
1863-
if check.conf.CompilerErrorMessages {
1864-
check.errorf(x, _TooManyValues, "multiple-value %s in single-value context", x)
1865-
} else {
1866-
check.errorf(x, _TooManyValues, "%d-valued %s where single value is expected", t.Len(), x)
1867-
}
1863+
check.errorf(x, _TooManyValues, "multiple-value %s in single-value context", x)
18681864
x.mode = invalid
18691865
}
18701866
}

src/go/types/expr.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,11 +1803,7 @@ func (check *Checker) singleValue(x *operand) {
18031803
// tuple types are never named - no need for underlying type below
18041804
if t, ok := x.typ.(*Tuple); ok {
18051805
assert(t.Len() != 1)
1806-
if compilerErrorMessages {
1807-
check.errorf(x, _TooManyValues, "multiple-value %s in single-value context", x)
1808-
} else {
1809-
check.errorf(x, _TooManyValues, "%d-valued %s where single value is expected", t.Len(), x)
1810-
}
1806+
check.errorf(x, _TooManyValues, "multiple-value %s in single-value context", x)
18111807
x.mode = invalid
18121808
}
18131809
}

src/internal/types/testdata/check/expr0.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ var (
175175
func g() (a, b int) { return }
176176

177177
func _() {
178-
_ = -g /* ERROR 2-valued g */ ()
179-
_ = <-g /* ERROR 2-valued g */ ()
178+
_ = -g /* ERROR multiple-value g */ ()
179+
_ = <-g /* ERROR multiple-value g */ ()
180180
}
181181

182182
// ~ is accepted as unary operator only permitted in interface type elements

src/internal/types/testdata/check/expr1.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ func _(x, y string, z mystring) {
120120
func f() (a, b int) { return }
121121

122122
func _(x int) {
123-
_ = f /* ERROR 2-valued f */ () + 1
124-
_ = x + f /* ERROR 2-valued f */ ()
125-
_ = f /* ERROR 2-valued f */ () + f
126-
_ = f /* ERROR 2-valued f */ () + f /* ERROR 2-valued f */ ()
123+
_ = f /* ERROR multiple-value f */ () + 1
124+
_ = x + f /* ERROR multiple-value f */ ()
125+
_ = f /* ERROR multiple-value f */ () + f
126+
_ = f /* ERROR multiple-value f */ () + f /* ERROR multiple-value f */ ()
127127
}

src/internal/types/testdata/check/expr3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ func _calls() {
554554
fi(1, 2.0, x, 3.14, "foo")
555555
fi(g2())
556556
fi(0, g2)
557-
fi(0, g2 /* ERROR "2-valued g2" */ ())
557+
fi(0, g2 /* ERROR "multiple-value g2" */ ())
558558
}
559559

560560
func issue6344() {

src/internal/types/testdata/check/issues0.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,21 @@ func issue9473(a []int, b ...int) {
6161
_ = append(f1())
6262
_ = append(f2 /* ERROR cannot use .* in argument */ ())
6363
_ = append(f2()... /* ERROR cannot use ... */ )
64-
_ = append(f0(), f1 /* ERROR 2-valued f1 */ ())
65-
_ = append(f0(), f2 /* ERROR 2-valued f2 */ ())
66-
_ = append(f0(), f1 /* ERROR 2-valued f1 */ ()...)
67-
_ = append(f0(), f2 /* ERROR 2-valued f2 */ ()...)
64+
_ = append(f0(), f1 /* ERROR multiple-value f1 */ ())
65+
_ = append(f0(), f2 /* ERROR multiple-value f2 */ ())
66+
_ = append(f0(), f1 /* ERROR multiple-value f1 */ ()...)
67+
_ = append(f0(), f2 /* ERROR multiple-value f2 */ ()...)
6868

6969
// variadic user-defined function
7070
append_(f0())
7171
append_(f0(), f0()...)
7272
append_(f1())
7373
append_(f2 /* ERROR cannot use .* in argument */ ())
7474
append_(f2()... /* ERROR cannot use ... */ )
75-
append_(f0(), f1 /* ERROR 2-valued f1 */ ())
76-
append_(f0(), f2 /* ERROR 2-valued f2 */ ())
77-
append_(f0(), f1 /* ERROR 2-valued f1 */ ()...)
78-
append_(f0(), f2 /* ERROR 2-valued f2 */ ()...)
75+
append_(f0(), f1 /* ERROR multiple-value f1 */ ())
76+
append_(f0(), f2 /* ERROR multiple-value f2 */ ())
77+
append_(f0(), f1 /* ERROR multiple-value f1 */ ()...)
78+
append_(f0(), f2 /* ERROR multiple-value f2 */ ()...)
7979
}
8080

8181
// Check that embedding a non-interface type in an interface results in a good error message.

src/internal/types/testdata/check/stmt0.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,14 +650,14 @@ func issue11667() {
650650

651651
func issue11687() {
652652
f := func() (_, _ int) { return }
653-
switch f /* ERROR "2-valued f" */ () {
653+
switch f /* ERROR "multiple-value f" */ () {
654654
}
655655
var x int
656-
switch f /* ERROR "2-valued f" */ () {
656+
switch f /* ERROR "multiple-value f" */ () {
657657
case x:
658658
}
659659
switch x {
660-
case f /* ERROR "2-valued f" */ ():
660+
case f /* ERROR "multiple-value f" */ ():
661661
}
662662
}
663663

src/internal/types/testdata/check/typeparams.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var _ = f(0 /* ERROR cannot use 0 .* as \[\]chan int */ )
3939

4040
func swap[A, B any](a A, b B) (B, A) { return b, a }
4141

42-
var _ = swap /* ERROR single value is expected */ [int, float32](1, 2)
42+
var _ = swap /* ERROR multiple-value */ [int, float32](1, 2)
4343
var f32, i = swap[int, float32](swap[float32, int](1, 2))
4444
var _ float32 = f32
4545
var _ int = i

src/internal/types/testdata/check/vardecl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var _ = 1, 2 /* ERROR "extra init expr 2" */
2828
var _, _ = 1 /* ERROR "cannot initialize [0-9]+ variables with [0-9]+ values" */
2929
var _, _, _ /* ERROR "missing init expr for _" */ = 1, 2
3030

31-
var _ = g /* ERROR "2-valued g" */ ()
31+
var _ = g /* ERROR "multiple-value g" */ ()
3232
var _, _ = g()
3333
var _, _, _ = g /* ERROR "cannot initialize [0-9]+ variables with [0-9]+ values" */ ()
3434

@@ -47,7 +47,7 @@ var (
4747
_, _ = 1 /* ERROR "cannot initialize [0-9]+ variables with [0-9]+ values" */
4848
_, _, _ /* ERROR "missing init expr for _" */ = 1, 2
4949

50-
_ = g /* ERROR "2-valued g" */ ()
50+
_ = g /* ERROR "multiple-value g" */ ()
5151
_, _ = g()
5252
_, _, _ = g /* ERROR "cannot initialize [0-9]+ variables with [0-9]+ values" */ ()
5353

0 commit comments

Comments
 (0)