tastrepr.nim 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. discard """
  2. output: '''
  3. var data = @[(1, "one"), (2, "two")]
  4. for (i, d) in pairs(data):
  5. discard
  6. for i, d in pairs(data):
  7. discard
  8. for i, (x, y) in pairs(data):
  9. discard
  10. var
  11. a = 1
  12. b = 2
  13. type
  14. A* = object
  15. var data = @[(1, "one"), (2, "two")]
  16. for (i, d) in pairs(data):
  17. discard
  18. for i, d in pairs(data):
  19. discard
  20. for i, (x, y) in pairs(data):
  21. discard
  22. var (a, b) = (1, 2)
  23. type
  24. A* = object
  25. var t04 = 1.0'f128
  26. t04 = 2.0'f128
  27. '''
  28. """
  29. import macros
  30. macro echoTypedRepr(arg: typed) =
  31. result = newCall(ident"echo", newLit(arg.repr))
  32. macro echoUntypedRepr(arg: untyped) =
  33. result = newCall(ident"echo", newLit(arg.repr))
  34. template echoTypedAndUntypedRepr(arg: untyped) =
  35. echoTypedRepr(arg)
  36. echoUntypedRepr(arg)
  37. echoTypedAndUntypedRepr:
  38. var data = @[(1,"one"), (2,"two")]
  39. for (i, d) in pairs(data):
  40. discard
  41. for i, d in pairs(data):
  42. discard
  43. for i, (x,y) in pairs(data):
  44. discard
  45. var (a,b) = (1,2)
  46. type A* = object # issue #22933
  47. echoUntypedRepr:
  48. var t04 = 1'f128
  49. t04 = 2'f128