3 // Copyright 2009 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.
7 // Verify that erroneous initialization expressions are caught by the compiler
21 var a1 = S{0, X: 1} // ERROR "mixture|undefined" "too few values"
22 var a2 = S{Y: 3, Z: 2, Y: 3} // ERROR "duplicate"
23 var a3 = T{S{}, 2, 3, 4, 5, 6} // ERROR "convert|too many"
24 var a4 = [5]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} // ERROR "index|too many"
25 var a5 = []byte{x: 2} // ERROR "index"
26 var a6 = []byte{1: 1, 2: 2, 1: 3} // ERROR "duplicate"
28 var ok1 = S{} // should be ok
29 var ok2 = T{S: ok1} // should be ok
31 // These keys can be computed at compile time but they are
32 // not constants as defined by the spec, so they do not trigger
33 // compile-time errors about duplicate key values.
36 type Key struct{ X, Y int }
38 var _ = map[Key]string{