summary refs log tree commit diff stats
path: root/tests/init/tlet.nim
blob: de0da23a69a39316dccb8dbc1b79a68322750ab6 (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
{.experimental: "strictDefs".}

proc bar(x: out string) =
  x = "abc"

proc foo() =
  block:
    let x: string
    if true:
      x = "abc"
    else:
      x = "def"
    doAssert x == "abc"
  block:
    let y: string
    bar(y)
    doAssert y == "abc"
  block:
    let x: string
    if true:
      x = "abc"
      discard "abc"
    else:
      x = "def"
      discard "def"
    doAssert x == "abc"
  block: #
    let x: int
  block: #
    let x: float
    x = 1.234
    doAssert x == 1.234
static: foo()
foo()