fixes #668
This commit is contained in:
parent
196977f623
commit
a5e4d2f7a3
3 changed files with 51 additions and 5 deletions
26
tests/ccgbugs/tobjconstr_bad_aliasing.nim
Normal file
26
tests/ccgbugs/tobjconstr_bad_aliasing.nim
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
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)]
|
||||
|
||||
when isMainModule:
|
||||
echo($dosomething()[0])
|
||||
Loading…
Add table
Add a link
Reference in a new issue