trepr.nim 984 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. discard """
  2. cmd: "nim c --gc:arc $file"
  3. nimout: '''(a: true, n: doAssert)
  4. Table[system.string, trepr.MyType](data: @[], counter: 0)
  5. nil
  6. '''
  7. output: '''
  8. nil
  9. 2
  10. Obj(member: ref @["hello"])
  11. ref (member: ref @["hello"])
  12. '''
  13. """
  14. import tables
  15. type
  16. NimSym = distinct NimNode
  17. MyType = tuple
  18. a: bool
  19. n: NimSym
  20. proc myproc(t: MyType) =
  21. echo repr(t)
  22. proc myproc2(t: MyType) =
  23. var x = Table[string, t]()
  24. echo repr(x)
  25. proc myproc3(t: MyType) =
  26. var x: TableRef[string, t]
  27. echo repr(x)
  28. macro dumpSym(a: typed) =
  29. myproc((a: true, n: NimSym(a)))
  30. myproc2((a: true, n: NimSym(a)))
  31. myproc3((a: true, n: NimSym(a)))
  32. dumpSym(doAssert)
  33. # bug 13731
  34. import os
  35. var a: File
  36. echo repr a
  37. # bug 13872
  38. echo repr(2'u16)
  39. # bug 14270
  40. type
  41. Obj = ref object
  42. member: ref seq[string]
  43. var c = Obj(member: new seq[string])
  44. c.member[] = @["hello"]
  45. echo c.repr
  46. var c2 = new tuple[member: ref seq[string]]
  47. c2.member = new seq[string]
  48. c2.member[] = @["hello"]
  49. echo c2.repr