ttypedesc3.nim 667 B

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