1
0
mirror of https://github.com/golang/go synced 2024-11-16 21:44:52 -07:00
go/test/fixedbugs/issue23732.go

43 lines
749 B
Go
Raw Normal View History

// errorcheck
// Copyright 2018 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.
// Issue 23732: Give better details about which struct
// initializer has the wrong number of values.
package main
type Foo struct {
A int
B int
C interface{}
Bar
}
type Bar struct {
A string
}
func main() {
test: match gofrontend error messages fixedbugs/issue20602.go:13:9: error: argument must have complex type fixedbugs/issue20602.go:14:9: error: argument must have complex type fixedbugs/issue19323.go:12:12: error: attempt to slice object that is not array, slice, or string fixedbugs/issue19323.go:18:13: error: attempt to slice object that is not array, slice, or string fixedbugs/issue20749.go:12:11: error: array index out of bounds fixedbugs/issue20749.go:15:11: error: array index out of bounds fixedbugs/issue20415.go:14:5: error: redefinition of ‘f’ fixedbugs/issue20415.go:12:5: note: previous definition of ‘f’ was here fixedbugs/issue20415.go:25:5: error: redefinition of ‘g’ fixedbugs/issue20415.go:20:5: note: previous definition of ‘g’ was here fixedbugs/issue20415.go:33:5: error: redefinition of ‘h’ fixedbugs/issue20415.go:31:5: note: previous definition of ‘h’ was here fixedbugs/issue19977.go:12:21: error: reference to undefined name ‘a’ fixedbugs/issue20812.go:10:13: error: invalid type conversion (cannot use type string as type int) fixedbugs/issue20812.go:11:13: error: invalid type conversion (cannot use type int as type bool) fixedbugs/issue20812.go:12:13: error: invalid type conversion (cannot use type string as type bool) fixedbugs/issue20812.go:13:13: error: invalid type conversion (cannot use type bool as type int) fixedbugs/issue20812.go:14:13: error: invalid type conversion (cannot use type bool as type string) fixedbugs/issue21256.go:9:5: error: redefinition of ‘main’ fixedbugs/issue20813.go:10:11: error: invalid left hand side of assignment fixedbugs/issue20185.go:22:16: error: ‘t’ declared but not used fixedbugs/issue20185.go:13:9: error: cannot type switch on non-interface value fixedbugs/issue20185.go:22:9: error: cannot type switch on non-interface value fixedbugs/issue20227.go:11:11: error: division by zero fixedbugs/issue20227.go:12:12: error: division by zero fixedbugs/issue20227.go:13:12: error: division by zero fixedbugs/issue20227.go:15:11: error: division by zero fixedbugs/issue20227.go:16:12: error: division by zero fixedbugs/issue19880.go:14:13: error: invalid use of type fixedbugs/issue23093.go:9:5: error: initialization expression for ‘f’ depends upon itself fixedbugs/issue21979.go:29:13: error: integer constant overflow fixedbugs/issue21979.go:39:13: error: complex constant truncated to floating-point fixedbugs/issue21979.go:10:13: error: invalid type conversion (cannot use type string as type bool) fixedbugs/issue21979.go:11:13: error: invalid type conversion (cannot use type int as type bool) fixedbugs/issue21979.go:12:13: error: invalid type conversion (cannot use type float64 as type bool) fixedbugs/issue21979.go:13:13: error: invalid type conversion (cannot use type complex128 as type bool) fixedbugs/issue21979.go:15:13: error: invalid type conversion (cannot use type bool as type string) fixedbugs/issue21979.go:17:13: error: invalid type conversion (cannot use type float64 as type string) fixedbugs/issue21979.go:18:13: error: invalid type conversion (cannot use type complex128 as type string) fixedbugs/issue21979.go:20:13: error: invalid type conversion (cannot use type string as type int) fixedbugs/issue21979.go:21:13: error: invalid type conversion (cannot use type bool as type int) fixedbugs/issue21979.go:27:13: error: invalid type conversion (cannot use type string as type uint) fixedbugs/issue21979.go:28:13: error: invalid type conversion (cannot use type bool as type uint) fixedbugs/issue21979.go:34:13: error: invalid type conversion (cannot use type string as type float64) fixedbugs/issue21979.go:35:13: error: invalid type conversion (cannot use type bool as type float64) fixedbugs/issue21979.go:41:13: error: invalid type conversion (cannot use type string as type complex128) fixedbugs/issue21979.go:42:13: error: invalid type conversion (cannot use type bool as type complex128) fixedbugs/issue21988.go:11:11: error: reference to undefined name ‘Wrong’ fixedbugs/issue22063.go:11:11: error: reference to undefined name ‘Wrong’ fixedbugs/issue22904.go:12:6: error: invalid recursive type ‘a’ fixedbugs/issue22904.go:13:6: error: invalid recursive type ‘b’ fixedbugs/issue22921.go:11:16: error: reference to undefined identifier ‘bytes.nonexist’ fixedbugs/issue22921.go:13:19: error: reference to undefined identifier ‘bytes.nonexist’ fixedbugs/issue22921.go:13:19: error: expected signature or type name fixedbugs/issue22921.go:17:15: error: reference to undefined identifier ‘bytes.buffer’ fixedbugs/issue23823.go:15:9: error: invalid recursive interface fixedbugs/issue23823.go:10:9: error: invalid recursive interface fixedbugs/issue23732.go:24:13: error: too few expressions for struct fixedbugs/issue23732.go:34:17: error: too many expressions for struct fixedbugs/issue23732.go:37:13: error: too few expressions for struct fixedbugs/issue23732.go:40:17: error: too many expressions for struct fixedbugs/issue22794.go:16:14: error: reference to undefined field or method ‘floats’ fixedbugs/issue22794.go:18:19: error: unknown field ‘floats’ in ‘it’ fixedbugs/issue22794.go:19:17: error: unknown field ‘InneR’ in ‘it’ fixedbugs/issue22794.go:18:9: error: ‘i2’ declared but not used fixedbugs/issue22822.go:15:17: error: expected function fixedbugs/issue25727.go:12:10: error: reference to unexported field or method ‘doneChan’ fixedbugs/issue25727.go:13:10: error: reference to undefined field or method ‘DoneChan’ fixedbugs/issue25727.go:14:21: error: unknown field ‘tlsConfig’ in ‘http.Server’ fixedbugs/issue25727.go:15:21: error: unknown field ‘DoneChan’ in ‘http.Server’ fixedbugs/issue25727.go:21:14: error: unknown field ‘bAr’ in ‘foo’ Change-Id: I32ce0b7d80017b2367b8fb479a881632240d4161 Reviewed-on: https://go-review.googlesource.com/c/go/+/277455 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-13 23:48:02 -07:00
_ = Foo{ // GCCGO_ERROR "too few expressions"
1,
2,
test: re-enable most go/tests that were disabled because of types2 differences I made the default be that, where there are differences between types2 and -G=0 error messages, we want errorcheck tests to pass types2. Typically, we can get errorcheck to pass on types2 and -G=0 if they give the same number of error messages on the same lines, just different wording. If they give a different number of error messages, then I made types2 pass. I added an exception list for -G=0 to cover those cases where -G=0 and types give different numbers of error messages. Because types2 does not run if there are syntax errors, for several tests, I had to split the tests into two parts in order to get all the indicated errors to be reported in types2 (bug228.go, bug388.go, issue11610.go, issue14520.go) I tried to preserve the GCCGO labeling correctly (but may have gotten some wrong). When types2 now matches where a GCCGO error previously occurred, I transformed GCCGO_ERROR -> ERROR. When types2 no longer reports an error in a certain place, I transformed ERROR -> GCCGO_ERROR. When types2 reports an error in a new place, I used GC_ERROR. The remaining entries in types2Failures are things that I think we probably still need to fix - either actually missing errors in types2, or cases where types2 gives worse errors than -G=0. Change-Id: I7f01e82b322b16094096b67d7ed2bb39b410c34f Reviewed-on: https://go-review.googlesource.com/c/go/+/372854 Trust: Dan Scales <danscales@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-12-03 17:10:10 -07:00
3,
} // GC_ERROR "too few values in"
_ = Foo{
1,
2,
3,
test: re-enable most go/tests that were disabled because of types2 differences I made the default be that, where there are differences between types2 and -G=0 error messages, we want errorcheck tests to pass types2. Typically, we can get errorcheck to pass on types2 and -G=0 if they give the same number of error messages on the same lines, just different wording. If they give a different number of error messages, then I made types2 pass. I added an exception list for -G=0 to cover those cases where -G=0 and types give different numbers of error messages. Because types2 does not run if there are syntax errors, for several tests, I had to split the tests into two parts in order to get all the indicated errors to be reported in types2 (bug228.go, bug388.go, issue11610.go, issue14520.go) I tried to preserve the GCCGO labeling correctly (but may have gotten some wrong). When types2 now matches where a GCCGO error previously occurred, I transformed GCCGO_ERROR -> ERROR. When types2 no longer reports an error in a certain place, I transformed ERROR -> GCCGO_ERROR. When types2 reports an error in a new place, I used GC_ERROR. The remaining entries in types2Failures are things that I think we probably still need to fix - either actually missing errors in types2, or cases where types2 gives worse errors than -G=0. Change-Id: I7f01e82b322b16094096b67d7ed2bb39b410c34f Reviewed-on: https://go-review.googlesource.com/c/go/+/372854 Trust: Dan Scales <danscales@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-12-03 17:10:10 -07:00
Bar{"A", "B"}, // ERROR "too many values in|too many expressions"
}
test: match gofrontend error messages fixedbugs/issue20602.go:13:9: error: argument must have complex type fixedbugs/issue20602.go:14:9: error: argument must have complex type fixedbugs/issue19323.go:12:12: error: attempt to slice object that is not array, slice, or string fixedbugs/issue19323.go:18:13: error: attempt to slice object that is not array, slice, or string fixedbugs/issue20749.go:12:11: error: array index out of bounds fixedbugs/issue20749.go:15:11: error: array index out of bounds fixedbugs/issue20415.go:14:5: error: redefinition of ‘f’ fixedbugs/issue20415.go:12:5: note: previous definition of ‘f’ was here fixedbugs/issue20415.go:25:5: error: redefinition of ‘g’ fixedbugs/issue20415.go:20:5: note: previous definition of ‘g’ was here fixedbugs/issue20415.go:33:5: error: redefinition of ‘h’ fixedbugs/issue20415.go:31:5: note: previous definition of ‘h’ was here fixedbugs/issue19977.go:12:21: error: reference to undefined name ‘a’ fixedbugs/issue20812.go:10:13: error: invalid type conversion (cannot use type string as type int) fixedbugs/issue20812.go:11:13: error: invalid type conversion (cannot use type int as type bool) fixedbugs/issue20812.go:12:13: error: invalid type conversion (cannot use type string as type bool) fixedbugs/issue20812.go:13:13: error: invalid type conversion (cannot use type bool as type int) fixedbugs/issue20812.go:14:13: error: invalid type conversion (cannot use type bool as type string) fixedbugs/issue21256.go:9:5: error: redefinition of ‘main’ fixedbugs/issue20813.go:10:11: error: invalid left hand side of assignment fixedbugs/issue20185.go:22:16: error: ‘t’ declared but not used fixedbugs/issue20185.go:13:9: error: cannot type switch on non-interface value fixedbugs/issue20185.go:22:9: error: cannot type switch on non-interface value fixedbugs/issue20227.go:11:11: error: division by zero fixedbugs/issue20227.go:12:12: error: division by zero fixedbugs/issue20227.go:13:12: error: division by zero fixedbugs/issue20227.go:15:11: error: division by zero fixedbugs/issue20227.go:16:12: error: division by zero fixedbugs/issue19880.go:14:13: error: invalid use of type fixedbugs/issue23093.go:9:5: error: initialization expression for ‘f’ depends upon itself fixedbugs/issue21979.go:29:13: error: integer constant overflow fixedbugs/issue21979.go:39:13: error: complex constant truncated to floating-point fixedbugs/issue21979.go:10:13: error: invalid type conversion (cannot use type string as type bool) fixedbugs/issue21979.go:11:13: error: invalid type conversion (cannot use type int as type bool) fixedbugs/issue21979.go:12:13: error: invalid type conversion (cannot use type float64 as type bool) fixedbugs/issue21979.go:13:13: error: invalid type conversion (cannot use type complex128 as type bool) fixedbugs/issue21979.go:15:13: error: invalid type conversion (cannot use type bool as type string) fixedbugs/issue21979.go:17:13: error: invalid type conversion (cannot use type float64 as type string) fixedbugs/issue21979.go:18:13: error: invalid type conversion (cannot use type complex128 as type string) fixedbugs/issue21979.go:20:13: error: invalid type conversion (cannot use type string as type int) fixedbugs/issue21979.go:21:13: error: invalid type conversion (cannot use type bool as type int) fixedbugs/issue21979.go:27:13: error: invalid type conversion (cannot use type string as type uint) fixedbugs/issue21979.go:28:13: error: invalid type conversion (cannot use type bool as type uint) fixedbugs/issue21979.go:34:13: error: invalid type conversion (cannot use type string as type float64) fixedbugs/issue21979.go:35:13: error: invalid type conversion (cannot use type bool as type float64) fixedbugs/issue21979.go:41:13: error: invalid type conversion (cannot use type string as type complex128) fixedbugs/issue21979.go:42:13: error: invalid type conversion (cannot use type bool as type complex128) fixedbugs/issue21988.go:11:11: error: reference to undefined name ‘Wrong’ fixedbugs/issue22063.go:11:11: error: reference to undefined name ‘Wrong’ fixedbugs/issue22904.go:12:6: error: invalid recursive type ‘a’ fixedbugs/issue22904.go:13:6: error: invalid recursive type ‘b’ fixedbugs/issue22921.go:11:16: error: reference to undefined identifier ‘bytes.nonexist’ fixedbugs/issue22921.go:13:19: error: reference to undefined identifier ‘bytes.nonexist’ fixedbugs/issue22921.go:13:19: error: expected signature or type name fixedbugs/issue22921.go:17:15: error: reference to undefined identifier ‘bytes.buffer’ fixedbugs/issue23823.go:15:9: error: invalid recursive interface fixedbugs/issue23823.go:10:9: error: invalid recursive interface fixedbugs/issue23732.go:24:13: error: too few expressions for struct fixedbugs/issue23732.go:34:17: error: too many expressions for struct fixedbugs/issue23732.go:37:13: error: too few expressions for struct fixedbugs/issue23732.go:40:17: error: too many expressions for struct fixedbugs/issue22794.go:16:14: error: reference to undefined field or method ‘floats’ fixedbugs/issue22794.go:18:19: error: unknown field ‘floats’ in ‘it’ fixedbugs/issue22794.go:19:17: error: unknown field ‘InneR’ in ‘it’ fixedbugs/issue22794.go:18:9: error: ‘i2’ declared but not used fixedbugs/issue22822.go:15:17: error: expected function fixedbugs/issue25727.go:12:10: error: reference to unexported field or method ‘doneChan’ fixedbugs/issue25727.go:13:10: error: reference to undefined field or method ‘DoneChan’ fixedbugs/issue25727.go:14:21: error: unknown field ‘tlsConfig’ in ‘http.Server’ fixedbugs/issue25727.go:15:21: error: unknown field ‘DoneChan’ in ‘http.Server’ fixedbugs/issue25727.go:21:14: error: unknown field ‘bAr’ in ‘foo’ Change-Id: I32ce0b7d80017b2367b8fb479a881632240d4161 Reviewed-on: https://go-review.googlesource.com/c/go/+/277455 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-12-13 23:48:02 -07:00
_ = Foo{ // GCCGO_ERROR "too few expressions"
1,
2,
test: re-enable most go/tests that were disabled because of types2 differences I made the default be that, where there are differences between types2 and -G=0 error messages, we want errorcheck tests to pass types2. Typically, we can get errorcheck to pass on types2 and -G=0 if they give the same number of error messages on the same lines, just different wording. If they give a different number of error messages, then I made types2 pass. I added an exception list for -G=0 to cover those cases where -G=0 and types give different numbers of error messages. Because types2 does not run if there are syntax errors, for several tests, I had to split the tests into two parts in order to get all the indicated errors to be reported in types2 (bug228.go, bug388.go, issue11610.go, issue14520.go) I tried to preserve the GCCGO labeling correctly (but may have gotten some wrong). When types2 now matches where a GCCGO error previously occurred, I transformed GCCGO_ERROR -> ERROR. When types2 no longer reports an error in a certain place, I transformed ERROR -> GCCGO_ERROR. When types2 reports an error in a new place, I used GC_ERROR. The remaining entries in types2Failures are things that I think we probably still need to fix - either actually missing errors in types2, or cases where types2 gives worse errors than -G=0. Change-Id: I7f01e82b322b16094096b67d7ed2bb39b410c34f Reviewed-on: https://go-review.googlesource.com/c/go/+/372854 Trust: Dan Scales <danscales@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-12-03 17:10:10 -07:00
Bar{"A", "B"}, // ERROR "too many values in|too many expressions"
} // GC_ERROR "too few values in"
}