tissues.nim 631 B

1234567891011121314151617181920212223242526272829
  1. import macros
  2. block t9043: # issue #9043
  3. proc foo[N: static[int]](dims: array[N, int]): string =
  4. const N1 = N
  5. const N2 = dims.len
  6. const ret = $(N, dims.len, N1, N2)
  7. static: doAssert ret == $(N, dims.len, N1, N2)
  8. ret
  9. doAssert foo([1, 2]) == "(2, 2, 2, 2)"
  10. block t4952:
  11. proc doCheck(tree: NimNode) =
  12. let res: tuple[n: NimNode] = (n: tree)
  13. assert: tree.kind == res.n.kind
  14. for sub in tree:
  15. doCheck(sub)
  16. macro id(body: untyped): untyped =
  17. doCheck(body)
  18. id(foo((i: int)))
  19. static:
  20. let tree = newTree(nnkExprColonExpr)
  21. let t = (n: tree)
  22. assert: t.n.kind == tree.kind