tpostfixcustompragma.nim 521 B

12345678910111213141516171819202122232425
  1. # issue #24526
  2. import std/macros
  3. template prag {.pragma.}
  4. type
  5. Foo1* = ref object of RootObj
  6. name*: string
  7. Foo2* {.used.} = ref object of RootObj
  8. name*: string
  9. Foo3* {.prag.} = ref object of RootObj
  10. name*: string
  11. Foo4* {.used, prag.} = ref object of RootObj
  12. name*: string
  13. # needs to have `typedesc` type
  14. proc foo(T: typedesc): bool =
  15. T.hasCustomPragma(prag)
  16. doAssert not foo(typeof(Foo1()[]))
  17. doAssert not foo(typeof(Foo2()[]))
  18. doAssert foo(typeof(Foo3()[]))
  19. doAssert foo(typeof(Foo4()[]))