tissues.nim 596 B

12345678910111213141516171819202122232425262728293031
  1. discard """
  2. nimout: "(Field0: 2, Field1: 2, Field2: 2, Field3: 2)"
  3. """
  4. import macros
  5. block t9043:
  6. proc foo[N: static[int]](dims: array[N, int])=
  7. const N1 = N
  8. const N2 = dims.len
  9. static: echo (N, dims.len, N1, N2)
  10. foo([1, 2])
  11. block t4952:
  12. proc doCheck(tree: NimNode) =
  13. let res: tuple[n: NimNode] = (n: tree)
  14. assert: tree.kind == res.n.kind
  15. for sub in tree:
  16. doCheck(sub)
  17. macro id(body: untyped): untyped =
  18. doCheck(body)
  19. id(foo((i: int)))
  20. static:
  21. let tree = newTree(nnkExprColonExpr)
  22. let t = (n: tree)
  23. assert: t.n.kind == tree.kind