]> Cypherpunks.ru repositories - gostls13.git/blob - test/initializerr.go
tests for new initializer syntax
[gostls13.git] / test / initializerr.go
1 // errchk $G -e $D/$F.go
2
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.
6
7 package main
8
9 type S struct {
10         A, B, C, X, Y, Z int;
11 }
12
13 type T struct {
14         S;
15 }
16
17 var x = 1
18 var a1 = S { 0, X: 1 }; // ERROR "mixture"
19 var a2 = S { Y: 3, Z: 2, Y: 3 }; // ERROR "duplicate"
20 var a3 = T { 1, 2, 3, 4, 5, 6 };        // ERROR "convert"
21 var a4 = [5]byte{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }       // ERROR "index"
22 var a5 = []byte { x: 2 }        // ERROR "index"
23
24 var ok1 = S { } // should be ok
25 var ok2 = T { S: a4 }   // should be ok