texpandmacro.nim 316 B

12345678910111213141516171819
  1. discard """
  2. cmd: "nim c --expandMacro:foo $file"
  3. nimout: '''texpandmacro.nim(17, 1) Hint: expanded macro:
  4. echo ["injected echo"]
  5. var x = 4 [ExpandMacro]
  6. '''
  7. output: '''injected echo'''
  8. """
  9. import macros
  10. macro foo(x: untyped): untyped =
  11. result = quote do:
  12. echo "injected echo"
  13. `x`
  14. foo:
  15. var x = 4