ttypedesc3.nim 700 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. discard """
  2. matrix: "--mm:arc; --mm:refc"
  3. output: '''
  4. proc Base
  5. proc Child
  6. method Base
  7. method Child
  8. yield Base
  9. yield Child
  10. 12
  11. 1
  12. '''
  13. """
  14. import typetraits
  15. type
  16. Base = object of RootObj
  17. Child = object of Base
  18. proc pr(T: type[Base]) = echo "proc " & T.name
  19. method me(T: type[Base]) = echo "method " & T.name
  20. iterator it(T: type[Base]): auto = yield "yield " & T.name
  21. Base.pr
  22. Child.pr
  23. Base.me
  24. Child.me #<- bug #2710
  25. for s in Base.it: echo s
  26. for s in Child.it: echo s #<- bug #2662
  27. # bug #11747
  28. type
  29. MyType = object
  30. a: int32
  31. b: int32
  32. c: int32
  33. MyRefType = ref MyType
  34. echo sizeof(default(MyRefType)[])
  35. type
  36. Foo[T] = object
  37. val: T
  38. var x: Foo[int].val
  39. inc(x)
  40. echo x