ttypedescnotnimnode.nim 701 B

12345678910111213141516171819202122
  1. discard """
  2. errormsg: "type mismatch: got <NimNode> but expected 'typedesc'"
  3. line: 14
  4. """
  5. import macros
  6. # This is the same example as ttypeselectors but using a proc instead of a macro
  7. # Instead of type mismatch for macro, proc just failed with internal error: getTypeDescAux(tyNone)
  8. # https://github.com/nim-lang/Nim/issues/7231
  9. proc getBase2*(bits: static[int]): typedesc =
  10. if bits == 128:
  11. result = newTree(nnkBracketExpr, ident("MpUintBase"), ident("uint64"))
  12. else:
  13. result = newTree(nnkBracketExpr, ident("MpUintBase"), ident("uint32"))
  14. type
  15. MpUint2*[bits: static[int]] = getbase2(bits)
  16. # technically shouldn't error until instantiation, so instantiate it
  17. var x: MpUint2[123]