summary refs log tree commit diff stats
path: root/tests/generics/tgenericrefs.nim
blob: a44b96af9b5fa29a9e7741d31814583c75b74e8c (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
36
37
38
type 
  PA[T] = ref TA[T]
  TA[T] = object
    field: T
var a: PA[string]
new(a)
a.field = "some string"


proc someOther[T](len: string): seq[T] = discard
proc someOther[T](len: int): seq[T] = echo "we"

proc foo[T](x: T) =
  var s = someOther[T](34)
  #newSeq[T](34)

foo 23



when false:
  # Compiles unless you use var a: PA[string]
  type 
    PA = ref TA
    TA[T] = object


  # Cannot instantiate:
  type 
    TA[T] = object
      a: PA[T]
    PA[T] = ref TA[T]

  type 
    PA[T] = ref TA[T]
    TA[T] = object