summary refs log tree commit diff stats
path: root/tests/js/trefbyvar.nim
blob: 68dd365430c960d3092cbad9600952810604c7df (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
discard """
  output: '''0
5
0
5'''
"""

# bug #2476

type A = ref object
    m: int

proc f(a: var A) =
    var b: A
    b.new()
    b.m = 5
    a = b

var t: A
t.new()

echo t.m
t.f()
echo t.m

proc main =
  # now test the same for locals
  var t: A
  t.new()

  echo t.m
  t.f()
  echo t.m

main()