summary refs log tree commit diff stats
path: root/tests/ccgbugs/tobjconstr_bad_aliasing.nim
blob: 9f6045364b3e138276db9a966a216be9fb2ad820 (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
discard """
  output: '''(10, (20, ))'''
"""

import strutils, sequtils

# bug #668

type
  TThing = ref object
    data: int
    children: seq[TThing]

proc `$`(t: TThing): string =
  result = "($1, $2)" % @[$t.data, join(map(t.children, proc(th: TThing): string = $th), ", ")]

proc somethingelse(): seq[TThing] =
  result = @[TThing(data: 20, children: @[])]

proc dosomething(): seq[TThing] =
  result = somethingelse()

  result = @[TThing(data: 10, children: result)]

echo($dosomething()[0])