aboutsummaryrefslogtreecommitdiff
path: root/test/fixedbugs
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2022-09-28 14:13:24 -0700
committerGopher Robot <gobot@golang.org>2022-09-28 22:28:39 +0000
commit7997e5f2540deb03a88a2f68f83bb5e5b7d6f77e (patch)
tree9751a58de41b9d7a292a40d9f3b31224d5f0d3b8 /test/fixedbugs
parent435652b468f0b71266f760490896ac3e9cf46eba (diff)
downloadgo-7997e5f2540deb03a88a2f68f83bb5e5b7d6f77e.tar.xz
cmd/compile: use "cannot use %s as %s value in %s: %s" error message
This is close to what the compiler used to say, except now we say "as T value" rather than "as type T" which is closer to the truth (we cannot use a value as a type, after all). Also, place the primary error and the explanation (cause) on a single line. Make respective (single line) adjustment to the matching "cannot convert" error. Adjust various tests. For #55326. Change-Id: Ib646cf906b11f4129b7ed0c38cf16471f9266b88 Reviewed-on: https://go-review.googlesource.com/c/go/+/436176 Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'test/fixedbugs')
-rw-r--r--test/fixedbugs/bug389.go2
-rw-r--r--test/fixedbugs/issue17645.go2
-rw-r--r--test/fixedbugs/issue48471.go16
-rw-r--r--test/fixedbugs/issue5358.go2
4 files changed, 11 insertions, 11 deletions
diff --git a/test/fixedbugs/bug389.go b/test/fixedbugs/bug389.go
index 209be8e6f7..3e8adb9728 100644
--- a/test/fixedbugs/bug389.go
+++ b/test/fixedbugs/bug389.go
@@ -9,4 +9,4 @@ package foo
func fn(a float32) {}
-var f func(arg int) = fn // ERROR "cannot use fn .type func.float32.. as type func.int. in assignment|different parameter types|cannot use fn .*type func.*float32.. as type func.*int. in variable declaration"
+var f func(arg int) = fn // ERROR "different parameter types|cannot use fn .*type func.*float32.. as func.*int. value in variable declaration"
diff --git a/test/fixedbugs/issue17645.go b/test/fixedbugs/issue17645.go
index 111fa81e13..6eed5f1a38 100644
--- a/test/fixedbugs/issue17645.go
+++ b/test/fixedbugs/issue17645.go
@@ -12,5 +12,5 @@ type Foo struct {
func main() {
var s []int
- var _ string = append(s, Foo{""}) // ERROR "cannot use .. \(.*untyped string.*\) as .*int.*|incompatible type" "cannot use Foo{.*} \(.*type Foo\) as type int in .*append" "cannot use append\(s\, Foo{.*}\) \(.*type \[\]int\) as type string in (assignment|variable declaration)"
+ var _ string = append(s, Foo{""}) // ERROR "cannot use append\(s, Foo{…}\) .* as string value in variable declaration" "cannot use Foo{…} .* as int value in argument to append" "cannot use .* as int value in struct literal"
}
diff --git a/test/fixedbugs/issue48471.go b/test/fixedbugs/issue48471.go
index 8b8d64370a..062cb5ab95 100644
--- a/test/fixedbugs/issue48471.go
+++ b/test/fixedbugs/issue48471.go
@@ -33,17 +33,17 @@ func (T6) m(int) string { return "" }
func f(I)
func g() {
- f(new(T)) // ERROR "cannot use new\(T\) \(.*type \*T\) as type I in argument to f:\n\t\*T does not implement I \(missing method M\)"
+ f(new(T)) // ERROR "cannot use new\(T\) \(.*type \*T\) as I value in argument to f: \*T does not implement I \(missing method M\)"
var i I
- i = new(T) // ERROR "cannot use new\(T\) \(.*type \*T\) as type I in assignment:\n\t\*T does not implement I \(missing method M\)"
- i = I(new(T)) // ERROR "cannot convert new\(T\) \(.*type \*T\) to type I:\n\t\*T does not implement I \(missing method M\)"
- i = new(T2) // ERROR "cannot use new\(T2\) \(.*type \*T2\) as type I in assignment:\n\t\*T2 does not implement I \(missing method M\)\n\t\thave m\(int\)\n\t\twant M\(int\)"
+ i = new(T) // ERROR "cannot use new\(T\) \(.*type \*T\) as I value in assignment: \*T does not implement I \(missing method M\)"
+ i = I(new(T)) // ERROR "cannot convert new\(T\) \(.*type \*T\) to type I: \*T does not implement I \(missing method M\)"
+ i = new(T2) // ERROR "cannot use new\(T2\) \(.*type \*T2\) as I value in assignment: \*T2 does not implement I \(missing method M\)\n\t\thave m\(int\)\n\t\twant M\(int\)"
- i = new(T3) // ERROR "cannot use new\(T3\) \(.*type \*T3\) as type I in assignment:\n\t\*T3 does not implement I \(wrong type for method M\)\n\t\thave M\(string\)\n\t\twant M\(int\)"
+ i = new(T3) // ERROR "cannot use new\(T3\) \(.*type \*T3\) as I value in assignment: \*T3 does not implement I \(wrong type for method M\)\n\t\thave M\(string\)\n\t\twant M\(int\)"
- i = T4{} // ERROR "cannot use T4\{\} \(.*type T4\) as type I in assignment:\n\tT4 does not implement I \(method M has pointer receiver\)"
- i = new(I) // ERROR "cannot use new\(I\) \(.*type \*I\) as type I in assignment:\n\t\*I does not implement I \(type \*I is pointer to interface, not interface\)"
+ i = T4{} // ERROR "cannot use T4\{\} \(.*type T4\) as I value in assignment: T4 does not implement I \(method M has pointer receiver\)"
+ i = new(I) // ERROR "cannot use new\(I\) \(.*type \*I\) as I value in assignment: \*I does not implement I \(type \*I is pointer to interface, not interface\)"
_ = i.(*T2) // ERROR "impossible type assertion: i.\(\*T2\)\n\t\*T2 does not implement I \(missing method M\)\n\t\thave m\(int\)\n\t\twant M\(int\)"
_ = i.(*T3) // ERROR "impossible type assertion: i.\(\*T3\)\n\t\*T3 does not implement I \(wrong type for method M\)\n\t\thave M\(string\)\n\t\twant M\(int\)"
@@ -51,6 +51,6 @@ func g() {
_ = i.(T6) // ERROR "impossible type assertion: i.\(T6\)\n\tT6 does not implement I \(missing method M\)\n\t\thave m\(int\) string\n\t\twant M\(int\)"
var t *T4
- t = i // ERROR "cannot use i \(variable of type I\) as type \*T4 in assignment:\n\tneed type assertion"
+ t = i // ERROR "cannot use i \(variable of type I\) as \*T4 value in assignment: need type assertion"
_ = i
}
diff --git a/test/fixedbugs/issue5358.go b/test/fixedbugs/issue5358.go
index 25f1e521fe..cfe8a9242a 100644
--- a/test/fixedbugs/issue5358.go
+++ b/test/fixedbugs/issue5358.go
@@ -13,5 +13,5 @@ func f(x int, y ...int) {}
func g() (int, []int)
func main() {
- f(g()) // ERROR "as type int in|incompatible type"
+ f(g()) // ERROR "as int value in|incompatible type"
}