tconstraints.nim 292 B

1234567891011121314151617
  1. discard """
  2. errormsg: "type mismatch: got <int literal(232)>"
  3. line: 16
  4. """
  5. proc myGenericProc[T: object|tuple|ptr|ref|distinct](x: T): string =
  6. result = $x
  7. type
  8. TMyObj = tuple[x, y: int]
  9. var
  10. x: TMyObj
  11. assert myGenericProc(x) == "(x: 0, y: 0)"
  12. assert myGenericProc(232) == "232"