| 1 |
// errorcheck |
| 2 |
|
| 3 |
// Copyright 2018 The Go Authors. All rights reserved. |
| 4 |
// Use of this source code is governed by a BSD-style |
| 5 |
// license that can be found in the LICENSE file. |
| 6 |
|
| 7 |
// Issue 23732: Give better details about which struct |
| 8 |
// initializer has the wrong number of values. |
| 9 |
|
| 10 |
package main |
| 11 |
|
| 12 |
type Foo struct { |
| 13 |
A int |
| 14 |
B int |
| 15 |
C interface{} |
| 16 |
Bar |
| 17 |
} |
| 18 |
|
| 19 |
type Bar struct { |
| 20 |
A string |
| 21 |
} |
| 22 |
|
| 23 |
func main() { |
| 24 |
_ = Foo{ // GCCGO_ERROR "too few expressions" |
| 25 |
1, |
| 26 |
2, |
| 27 |
3, |
| 28 |
} // GC_ERROR "too few values in" |
| 29 |
|
| 30 |
_ = Foo{ |
| 31 |
1, |
| 32 |
2, |
| 33 |
3, |
| 34 |
Bar{"A", "B"}, // ERROR "too many values in|too many expressions" |
| 35 |
} |
| 36 |
|
| 37 |
_ = Foo{ // GCCGO_ERROR "too few expressions" |
| 38 |
1, |
| 39 |
2, |
| 40 |
Bar{"A", "B"}, // ERROR "too many values in|too many expressions" |
| 41 |
} // GC_ERROR "too few values in" |
| 42 |
} |