]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: use "multiple-value" instead "n-valued" in error messages
authorRobert Griesemer <gri@golang.org>
Mon, 26 Sep 2022 18:47:22 +0000 (11:47 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 27 Sep 2022 21:14:06 +0000 (21:14 +0000)
This matches current compiler behavior.

For #55326.

Change-Id: I9ebe2914323072b5454fb9af2d15c9dd2d711bad
Reviewed-on: https://go-review.googlesource.com/c/go/+/434735
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

src/cmd/compile/internal/types2/expr.go
src/go/types/expr.go
src/internal/types/testdata/check/expr0.go
src/internal/types/testdata/check/expr1.go
src/internal/types/testdata/check/expr3.go
src/internal/types/testdata/check/issues0.go
src/internal/types/testdata/check/stmt0.go
src/internal/types/testdata/check/typeparams.go
src/internal/types/testdata/check/vardecl.go

index 25c822dba8e2953249bf68d549a35744a1a19138..3e82e4bcca42c08ed26dc18afcbcf29d4f801c23 100644 (file)
@@ -1860,11 +1860,7 @@ func (check *Checker) singleValue(x *operand) {
                // tuple types are never named - no need for underlying type below
                if t, ok := x.typ.(*Tuple); ok {
                        assert(t.Len() != 1)
-                       if check.conf.CompilerErrorMessages {
-                               check.errorf(x, _TooManyValues, "multiple-value %s in single-value context", x)
-                       } else {
-                               check.errorf(x, _TooManyValues, "%d-valued %s where single value is expected", t.Len(), x)
-                       }
+                       check.errorf(x, _TooManyValues, "multiple-value %s in single-value context", x)
                        x.mode = invalid
                }
        }
index cc1db30feffbfe7350ec48279aae6867258d41b5..12f73947fd6042d682f77fc0ee1959f570307d10 100644 (file)
@@ -1803,11 +1803,7 @@ func (check *Checker) singleValue(x *operand) {
                // tuple types are never named - no need for underlying type below
                if t, ok := x.typ.(*Tuple); ok {
                        assert(t.Len() != 1)
-                       if compilerErrorMessages {
-                               check.errorf(x, _TooManyValues, "multiple-value %s in single-value context", x)
-                       } else {
-                               check.errorf(x, _TooManyValues, "%d-valued %s where single value is expected", t.Len(), x)
-                       }
+                       check.errorf(x, _TooManyValues, "multiple-value %s in single-value context", x)
                        x.mode = invalid
                }
        }
index 19923777df1d475533dbbaff3a1f3e9b316103f9..dd86eca535ced5f336b428ea8f3d6ffbdfaaa676 100644 (file)
@@ -175,8 +175,8 @@ var (
 func g() (a, b int) { return }
 
 func _() {
-       _ = -g /* ERROR 2-valued g */ ()
-       _ = <-g /* ERROR 2-valued g */ ()
+       _ = -g /* ERROR multiple-value g */ ()
+       _ = <-g /* ERROR multiple-value g */ ()
 }
 
 // ~ is accepted as unary operator only permitted in interface type elements
index 42b95fbb37bec2810aaff3a75b73d2e2ca79b8fc..49e8baed02c06e16a43f32a58d9cb4b15ef71164 100644 (file)
@@ -120,8 +120,8 @@ func _(x, y string, z mystring) {
 func f() (a, b int) { return }
 
 func _(x int) {
-       _ = f /* ERROR 2-valued f */ () + 1
-       _ = x + f /* ERROR 2-valued f */ ()
-       _ = f /* ERROR 2-valued f */ () + f
-       _ = f /* ERROR 2-valued f */ () + f /* ERROR 2-valued f */ ()
+       _ = f /* ERROR multiple-value f */ () + 1
+       _ = x + f /* ERROR multiple-value f */ ()
+       _ = f /* ERROR multiple-value f */ () + f
+       _ = f /* ERROR multiple-value f */ () + f /* ERROR multiple-value f */ ()
 }
index abe209201a4b3e0d2b80099cec53e7d7cbb4eca1..a28d119f4e00dc03888844761345b676f7bd7004 100644 (file)
@@ -554,7 +554,7 @@ func _calls() {
        fi(1, 2.0, x, 3.14, "foo")
        fi(g2())
        fi(0, g2)
-       fi(0, g2 /* ERROR "2-valued g2" */ ())
+       fi(0, g2 /* ERROR "multiple-value g2" */ ())
 }
 
 func issue6344() {
index 5f46021b94274a57cb61d7fbdbd5a79c8279369e..7581ec92bdd56b18b4e0abda50731d0c77221a2b 100644 (file)
@@ -61,10 +61,10 @@ func issue9473(a []int, b ...int) {
        _ = append(f1())
        _ = append(f2 /* ERROR cannot use .* in argument */ ())
        _ = append(f2()... /* ERROR cannot use ... */ )
-       _ = append(f0(), f1 /* ERROR 2-valued f1 */ ())
-       _ = append(f0(), f2 /* ERROR 2-valued f2 */ ())
-       _ = append(f0(), f1 /* ERROR 2-valued f1 */ ()...)
-       _ = append(f0(), f2 /* ERROR 2-valued f2 */ ()...)
+       _ = append(f0(), f1 /* ERROR multiple-value f1 */ ())
+       _ = append(f0(), f2 /* ERROR multiple-value f2 */ ())
+       _ = append(f0(), f1 /* ERROR multiple-value f1 */ ()...)
+       _ = append(f0(), f2 /* ERROR multiple-value f2 */ ()...)
 
        // variadic user-defined function
        append_(f0())
@@ -72,10 +72,10 @@ func issue9473(a []int, b ...int) {
        append_(f1())
        append_(f2 /* ERROR cannot use .* in argument */ ())
        append_(f2()... /* ERROR cannot use ... */ )
-       append_(f0(), f1 /* ERROR 2-valued f1 */ ())
-       append_(f0(), f2 /* ERROR 2-valued f2 */ ())
-       append_(f0(), f1 /* ERROR 2-valued f1 */ ()...)
-       append_(f0(), f2 /* ERROR 2-valued f2 */ ()...)
+       append_(f0(), f1 /* ERROR multiple-value f1 */ ())
+       append_(f0(), f2 /* ERROR multiple-value f2 */ ())
+       append_(f0(), f1 /* ERROR multiple-value f1 */ ()...)
+       append_(f0(), f2 /* ERROR multiple-value f2 */ ()...)
 }
 
 // Check that embedding a non-interface type in an interface results in a good error message.
index 3dc5681cb879ca312217c3343b9d5f63cfc06654..7eabbef8ad1a620f7d06492174f985a573642159 100644 (file)
@@ -650,14 +650,14 @@ func issue11667() {
 
 func issue11687() {
        f := func() (_, _ int) { return }
-       switch f /* ERROR "2-valued f" */ () {
+       switch f /* ERROR "multiple-value f" */ () {
        }
        var x int
-       switch f /* ERROR "2-valued f" */ () {
+       switch f /* ERROR "multiple-value f" */ () {
        case x:
        }
        switch x {
-       case f /* ERROR "2-valued f" */ ():
+       case f /* ERROR "multiple-value f" */ ():
        }
 }
 
index 766500c6b99ef70c681370952cf6dd12d09ab3c4..b7950bf0be5a934799fea9b5d8d37c0dbc541113 100644 (file)
@@ -39,7 +39,7 @@ var _ = f(0 /* ERROR cannot use 0 .* as \[\]chan int */ )
 
 func swap[A, B any](a A, b B) (B, A) { return b, a }
 
-var _ = swap /* ERROR single value is expected */ [int, float32](1, 2)
+var _ = swap /* ERROR multiple-value */ [int, float32](1, 2)
 var f32, i = swap[int, float32](swap[float32, int](1, 2))
 var _ float32 = f32
 var _ int = i
index 6b6a45bc7738ff87d5cdef2753c31311ba258073..732225d92691fc17b8bdbd96a3231892f6a3b690 100644 (file)
@@ -28,7 +28,7 @@ var _ = 1, 2 /* ERROR "extra init expr 2" */
 var _, _ = 1 /* ERROR "cannot initialize [0-9]+ variables with [0-9]+ values" */
 var _, _, _ /* ERROR "missing init expr for _" */ = 1, 2
 
-var _ = g /* ERROR "2-valued g" */ ()
+var _ = g /* ERROR "multiple-value g" */ ()
 var _, _ = g()
 var _, _, _ = g /* ERROR "cannot initialize [0-9]+ variables with [0-9]+ values" */ ()
 
@@ -47,7 +47,7 @@ var (
        _, _ = 1 /* ERROR "cannot initialize [0-9]+ variables with [0-9]+ values" */
        _, _, _ /* ERROR "missing init expr for _" */ = 1, 2
 
-       _ = g /* ERROR "2-valued g" */ ()
+       _ = g /* ERROR "multiple-value g" */ ()
        _, _ = g()
        _, _, _ = g /* ERROR "cannot initialize [0-9]+ variables with [0-9]+ values" */ ()