macro_bug.nim 374 B

12345678910111213141516171819
  1. import macros
  2. macro macro_bug*(s: untyped) =
  3. echo s.treeRepr
  4. s.expectKind({nnkProcDef, nnkMethodDef})
  5. var params = s.params
  6. let genericParams = s[2]
  7. result = newNimNode(nnkProcDef).add(
  8. s.name, s[1], genericParams, params, pragma(s), newEmptyNode())
  9. # don't really do anything
  10. var body = body(s)
  11. result.add(body)
  12. echo "result:"
  13. echo result.repr