tgettype.nim 568 B

12345678910111213141516171819202122232425262728
  1. discard """
  2. msg: '''ObjectTy(Sym(Model), RecList(Sym(name), Sym(password)))
  3. BracketExpr(Sym(typeDesc), Sym(User))'''
  4. """
  5. import strutils, macros
  6. type
  7. Model = object of RootObj
  8. User = object of Model
  9. name : string
  10. password : string
  11. macro testUser: string =
  12. result = newLit(User.getType.lispRepr)
  13. macro testGeneric(T: typedesc[Model]): string=
  14. result = newLit(T.getType.lispRepr)
  15. echo testUser
  16. echo User.testGeneric
  17. macro assertVoid(e: typed): untyped =
  18. assert(getTypeInst(e).typeKind == ntyVoid)
  19. proc voidProc() = discard
  20. assertVoid voidProc()