aboutsummaryrefslogtreecommitdiff
path: root/compiler/tests/verifier/type_compatibility.bad
blob: a13e30b1150cded5ab12415ba50c2fdc222e18cc (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
59
60
61
62
63
64
65
66
67
68
69


/* ERRORS; Named type & named type => identity comparison */
int a = tt;
T b = ii;

/* ERRORS: Named & anonymous types => structure comparison */
() c = ii;
U d = tt;
V e = ();

/* ERRORS */
int^ f = @b;
T^ g = @a;

/* ERRORS */
()^ h = @a;
(RT1 x) i = h^;
(RT2 x) j = i;
byte^ k = @u16;
uint16^ l = @byt;

/* ERRORS byte and char require explicit "as uint8" expressions */
byte^ bp1 = @ch;
char^ cp1 = @byt;
byte^ bp1 = charp;
char^ cp1 = bytep;

/* ERRORS structurally incompatible enums */
enum(true=0,false=1) k1 = bb;
int enum(false=4,true=0) k2 = bb;
int enum(false=0,nottrue=1) k3 = bb;
int enum(false=0,true=5) k4 = bb;
int enum(false=0) k5 = bb;

/* ERRORS: Function types */
FT1^ fp1 = @fun;
FT2^ fp2 = fp1;

(short)#[2] arr1 = [(1,), (2,)];
/* ERRORS: structure of array element types must match exactly */
(int)#[2] arr2 = arr1;

// types to test with
typedef T = ();
typedef U = ();
typedef TPtr = T^;  // bad code style!
typedef UPtr = U^;
typedef V = (int x);
typedef W = (int x, int y);
typedef RT1 = (T x);
typedef RT2 = (T x);

typedef FT1 = T(T a, T b);
typedef FT2 = T(T a, T b);


// values to test with
int ii = 0;
T tt = ();
bool bb = :false;
byte byt = 10;
char ch = 32;
byte^ bytep = @byt;
char^ charp = @ch;
uint16 u16 = 1234;

// functions to test with
T fun(T x, () y);