tcprag.nim 537 B

123456789101112131415161718192021222324252627282930313233
  1. discard """
  2. output: '''true
  3. true
  4. true
  5. '''
  6. """
  7. # issue #7615
  8. import macros
  9. template table(name: string) {.pragma.}
  10. type
  11. User {.table("tuser").} = object
  12. id: int
  13. name: string
  14. age: int
  15. echo User.hasCustomPragma(table)
  16. ## crash: Error: internal error: (filename: "sempass2.nim", line: 560, column: 19)
  17. macro m1(T: typedesc): untyped =
  18. getAST hasCustomPragma(T, table)
  19. echo m1(User) # Oops crash
  20. ## This works
  21. macro m2(T: typedesc): untyped =
  22. result = quote do:
  23. `T`.hasCustomPragma(table)
  24. echo m2(User)