t19426.nim 297 B

12345678910111213141516
  1. type
  2. MyInt = object
  3. bitWidth: int
  4. template toRealType*(t: MyInt): typedesc =
  5. when t.bitWidth == 32: int32
  6. elif t.bitWidth == 64: int64
  7. else: {.error.}
  8. proc doFail(T: typedesc): T = default(T)
  9. proc test =
  10. const myInt = MyInt(bitWidth:32)
  11. discard doFail(toRealType(myInt))
  12. test()