aboutsummaryrefslogtreecommitdiffstats
path: root/tests/semantics.bad
blob: d1effe41773e134402d537ddbeb165ffe970d402 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
; let a:f32 = (1.0 + 2.0 * 2.0) / 2.0

let a:int = (1 + 2 * 2) / 2
let b = 1
let c = b
let d = 1 + 2 * 4
let e = 1 <= 2
let booleans = !true && false || (1 <= 2)
let bits = 0xff & 0b00001111

; enum test {
;     a = 1
;     b
; }
; ; Resolve struct accessors.
; struct my_struct {
;     field_a: int
;     field_b: int
; }

; let a:my_struct
; set a.field_a = 1

; fun nested(): u32 {
;     fun adder(a: u32, b: u32): u32 a + b
;     if (1 + 1) {
;         {
;             let b = 32
;         }
;     }
;     adder(1,2)
; }

; enum field {
;     a
;     b
; }

; struct vec {
;     a: int
;     b: int
; }

; fun foo(): nil {
;     bar()
; }

; fun bar(): nil {
;     foo()
; }

; ; There are some builtint functions.
; println("hello world")

; ; Let/set.
; let num = 1
; set num = 2
; set num = 0 + num

; ; Loops and conditionals.
; if (num) 3 else 1
; let val = if (2 + num == 4) num else num
; if (true) {
;     let c = 1
;     1 + 1 + c
; }

; fun testmatches(): nil {
;     match (num) {
;         case 1 = 23
;         case 2 = num
;         else = num
;     }

;     cond {
;         case 1 == 1 = 23
;         case 2 != 1 = num
;         else = num
;     }
; }

; while (num == 1) num
; while (true) {
;     let c = 1
;     1 + 1 + c
; }

; This should err.
; fun foo(): nil {
;     1
; }
; let b = a
; let a = a
; set a = 10
; set num = 1 << a
; baz()
; if (a) 1
; if (num == 1) a
; if (num == 1) 1 else a