aboutsummaryrefslogtreecommitdiffstats
path: root/tests/semantics.bad
blob: 3479915419d2eb592a6582b77357bf1499e584e7 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
fun add10(a: int, b: str): int {
    a + 10
}

fun foo(): int {
    add10(1, "hello")
}

; let a:f32 = (1.0 + 2.0 * 2.0) / 2.0

; let annotated:int = (1 + 2 * 2) / 2
; let numbers = 1
; let symbols = numbers
; let arith = 1 + 2 * 4
; let cmp = 1 <= 2
; let logic = !true && false || (1 <= 2)
; let bits = 0xff & 0b00001111
; let block = {
;     let a = 1 + 2
;     a + 3
; }

; let maybe = if (1 == 2) {
;     32
; } else {
;     44
; }

; let single = if (true) {
;     123
; }

; while (!true) {
;     "asjdflasdjf"
; }

; set single = 32

; cond {
;     1 == 2 = "hello"
;     else = "dong"
; }

; 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(): int {
    fun adder(a: u32, b: u32): u32 {
        a + b
    }
    if (1 + 1 == 2) {
        let b = 15
        5 + b
    ;     {
    ;         let b = 32
    ;     }
    }
}

; 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(num: int): int {
; ;     match (num) {
; ;         case 1 = 23
; ;         case 2 = num
; ;         else = num
; ;     }

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

; while (num == 1) num
; while (true) {
;     let c = 1
;     1 + 1 + c
; }
; fun foo(a: int b: str): (f64, f64) {
;     fun bar(): nil {
;         println("ding")
;     }
;     if (a == 1) {
;         ; return("test", b)
;         return (3.0, 4.0)
;     }
;     return (1.0, 2.0)
; }

; 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