typeclassinference.nim 360 B

12345678910111213141516171819202122
  1. discard """
  2. errormsg: "type mismatch: got <string> but expected 'ptr'"
  3. line: 20
  4. """
  5. import typetraits
  6. type
  7. Vec[N: static[int]; T] = distinct array[N, T]
  8. var x = Vec([1, 2, 3])
  9. static:
  10. assert x.type.name == "Vec[3, system.int]"
  11. var str1: string = "hello, world!"
  12. var ptr1: ptr = addr(str1)
  13. var str2: string = "hello, world!"
  14. var ptr2: ptr = str2