tor.nim 487 B

1234567891011121314151617181920212223242526272829303132333435
  1. discard """
  2. output: '''
  3. 3
  4. 30
  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 =
  15. {.noRewrite.}:
  16. f(a mod 10, b)
  17. let xx = 10
  18. echo 10*xx
  19. template t{x = (~x){y} and (~x){z}}(x, y, z: bool): typed =
  20. x = y
  21. if x: x = z
  22. var
  23. a = true
  24. b = true
  25. c = false
  26. a = b and a
  27. echo a