vxx2 / vlib / v / checker / tests / goto_label.vv
37 lines · 35 sloc · 441 bytes · 1512486d01d4205e7b67ebd679238fa45cd348af
Raw
1fn f() {
2 unsafe {
3 goto f1 // forward
4 goto f2
5 f1:
6 goto a1
7 _ = fn () {
8 goto f1 // the `f1` label is not available here; it is in the outer scope
9 goto f2 // same with `f2`
10 goto a1 // this is ok
11 a1:
12 goto a1
13 }
14 f2:
15 goto a1
16 goto f1 // back
17 goto f2
18 }
19}
20
21fn g() {
22 unsafe {
23 goto g1 // forward
24 g1:
25 goto f1
26 goto a1
27 goto g1 // back
28 goto undefined
29 }
30}
31
32// implicit main
33unsafe {
34 goto m1
35 m1:
36 goto m1
37}
38