aboutsummaryrefslogtreecommitdiff
path: root/tests/structs.ek
blob: 20d9c488548630490f8baf9fd9d5048ea37e4405 (plain) (blame)
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
typedef any {}

struct basic_struct {
	a i64;
	b i64;
	c i64;
}

struct complex_struct (A any, B any, C any) {
	a A;
	b B;
	c C;
}

main()
{
	/* infer types */
	simple_named const = {.a = 1, .b = 2, .c = 3} as basic_struct;
	complex_named const = {.a = 1, .b = 2, .c = 3} as complex_struct;

	/* force types */
	force_named complex_struct![u32, u32, u32] = {.a = 1, .b = 2, .c = 3};
	force_inferred_named mut = {.a = 1, .b = 2, .c = 3} as
		complex_struct![u32, u32, u32];

	/* types should be inferred */
	force_inferred_named = {.a = 2, .b = 3, .c = 4};
}