summary refs log blame commit diff stats
path: root/tests/ccgbugs/tobjconstr_bad_aliasing.nim
blob: ea51ecacb6706596e032c1f17c613e86ea2a35d2 (plain) (tree)

























                                                                                               
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])
me/doc/docs.txt?h=devel&id=439aa2d04d5528b5aed288f70895515d1da2dc3d'>^
405b86068
439aa2d04 ^
405b86068

783273032 ^

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
36
37
38
39
40

                                                
                                    
                                                    
 
                                     
                                                                          
 
                                    
                                                                           
 
                                       
                                                   
 
                                      

                                                                        
 


                                                                       
                   
                                                                      

                     
                                         
                                                                          

                              
                                            
                                                                           

                  
                                           
                                                                              
                                          

                            

                                                    
The documentation consists of several documents:

- | `Tutorial (part I) <tut1.html>`_
  | The Nim tutorial part one deals with the basics.

- | `Tutorial (part II) <tut2.html>`_
  | The Nim tutorial part two deals with the advanced language constructs.

- | `Language Manual <manual.html>`_
  | The Nim manual is a draft that will evolve into a proper specification.

- | `Library documentation <lib.html>`_
  | This document describes Nim's standard library.

- | `Compiler user guide <nimc.html>`_
  | The user guide lists command line arguments, special features of the
    compiler, etc.

- | `Tools documentation <tools.html>`_
  | Description of some tools that come with the standard distribution.

- | `GC <gc.html>`_
  | Additional documentation about Nim's GC and how to operate it in a
  | realtime setting.

- | `Source code filters <filters.html>`_
  | The Nim compiler supports source code filters as a simple yet powerful
    builtin templating system.

- | `Term rewriting macros <trmacros.html>`_
  | Term rewriting macros enhance the compilation process with user defined
    optimizations.

- | `Internal documentation <intern.html>`_
  | The internal documentation describes how the compiler is implemented. Read
    this if you want to hack the compiler.

- | `Index <theindex.html>`_
  | The generated index. **Index + (Ctrl+F) == Joy**