summaryrefslogtreecommitdiff
path: root/tests/typ/expr/block-scoping.typ
blob: 7bb98969a18763e545e24d5f4b19bcee620e2c7e (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
29
30
31
32
33
34
35
// Test scoping with blocks.
// Ref: false

---
// Block in template does not create a scope.
{ let x = 1 }
#test(x, 1)

---
// Block in expression does create a scope.
#let a = {
    let b = 1
    b
}

#test(a, 1)

// Error: 2-3 unknown variable
{b}

---
// Multiple nested scopes.
{
    let a = "a1"
    {
        let a = "a2"
        {
            test(a, "a2")
            let a = "a3"
            test(a, "a3")
        }
        test(a, "a2")
    }
    test(a, "a1")
}