aboutsummaryrefslogtreecommitdiff
path: root/compiler/tests/parser/expr_exprlists.good
blob: 57776f0bd006dc061cffe5d0db1e1ce8b60af98e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58


int grouping = (1+2) * 3;

// Element lists
int#[0] arr0 = [];
int#[1] arr1 = [1];
int#[2] arr2 = [2,3];

() struct0 = ();
(int) struct1 = (1,);
(int,int) struct2 = (2,3);

// Argument lists
int x = arr1#[0];
int y = arr2d#[1,2];
int z = arr3d#[0,1,2];

() test() {
    // initial values of global variables need to be compile-time evalutable
    int u = f0args();
    int v = f1args(1);
    int w = f2args(2,3);
}

// Trailing comma in element lists
int#[1] ta = [1,];
(int) ts = (2,);



// Support code
int f0args() { return 0; }
int f1args(int) { return 0; }
int f2args(int,int) { return 0; }

int#[3,3] arr2d = [
    [11,12,13],
    [21,22,23],
    [31,32,33],
];
int#[3,3,3] arr3d = [
    [
        [111,112,113],
        [121,122,123],
        [131,132,133],
    ],
    [
        [211,212,213],
        [221,222,223],
        [231,232,233],
    ],
    [
        [311,312,313],
        [321,322,323],
        [331,332,333],
    ],
];