aboutsummaryrefslogtreecommitdiffstats
path: root/tests/conditionals.bad
blob: b1c6a8961147b5303c72900c735dcd2d9d5563c8 (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
; Basic if expressions.
if true "hello"

; These can produce values and the result bound to a name.
let a = if (2 + 2 >= 4) 42

; We support a single if expression.
let b = if 0xff == 255 "hello" else "world"

; ... but these can compound on each other
if 1 < 2        6
else if 1 > 2   7
else            8

; A block is an expression, and if raise the scope level regardless if a block
; is used or not.
if true != false {
    let a = "yo"
}

; Match cases should only apply to literal values, for example `case 1 + 2`
; isn't allowed. They should generally convert to a lookup table.
match a = {
    case 8 = "hello"
    case 9 = "world"
    else   = "what"
}