tor.nim 465 B

123456789101112131415161718192021222324252627282930313233
  1. discard """
  2. output: '''
  3. 3
  4. 0
  5. true
  6. '''
  7. """
  8. # bug #798
  9. template t012{(0|1|2){x}}(x: untyped): untyped = x+1
  10. let z = 1
  11. # outputs 3 thanks to fixpoint iteration:
  12. echo z
  13. template arithOps: untyped = (`+` | `-` | `*`)
  14. template testOr{ (arithOps{f})(a, b) }(a, b, f: untyped): untyped = f(a mod 10, b)
  15. let xx = 10
  16. echo 10*xx
  17. template t{x = (~x){y} and (~x){z}}(x, y, z: bool): typed =
  18. x = y
  19. if x: x = z
  20. var
  21. a = true
  22. b = true
  23. c = false
  24. a = b and a
  25. echo a