t3330.nim 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. discard """
  2. errormsg: "type mismatch: got <Bar[system.int]>"
  3. disabled: "true"
  4. nimout: '''
  5. t3330.nim(63, 4) Error: type mismatch: got <Bar[system.int]>
  6. but expected one of:
  7. proc test(foo: Foo[int])
  8. t3330.nim(48, 8) Hint: Non-matching candidates for add(k, string, T)
  9. proc add[T](x: var seq[T]; y: openArray[T])
  10. first type mismatch at position: 1
  11. required type: var seq[T]
  12. but expression 'k' is of type: Alias
  13. proc add(result: var string; x: float)
  14. first type mismatch at position: 1
  15. required type: var string
  16. but expression 'k' is of type: Alias
  17. proc add(x: var string; y: string)
  18. first type mismatch at position: 1
  19. required type: var string
  20. but expression 'k' is of type: Alias
  21. proc add(x: var string; y: cstring)
  22. first type mismatch at position: 1
  23. required type: var string
  24. but expression 'k' is of type: Alias
  25. proc add[T](x: var seq[T]; y: T)
  26. first type mismatch at position: 1
  27. required type: var seq[T]
  28. but expression 'k' is of type: Alias
  29. proc add(result: var string; x: int64)
  30. first type mismatch at position: 1
  31. required type: var string
  32. but expression 'k' is of type: Alias
  33. proc add(x: var string; y: char)
  34. first type mismatch at position: 1
  35. required type: var string
  36. but expression 'k' is of type: Alias
  37. t3330.nim(48, 8) template/generic instantiation of `add` from here
  38. t3330.nim(55, 6) Foo: 'bar.value' cannot be assigned to
  39. t3330.nim(48, 8) template/generic instantiation of `add` from here
  40. t3330.nim(56, 6) Foo: 'bar.x' cannot be assigned to
  41. expression: test(bar)'''
  42. """
  43. type
  44. Foo[T] = concept k
  45. add(k, string, T)
  46. Bar[T] = object
  47. value: T
  48. x: string
  49. proc add[T](bar: Bar[T], x: string, val: T) =
  50. bar.value = val
  51. bar.x = x
  52. proc test(foo: Foo[int]) =
  53. foo.add("test", 42)
  54. echo(foo.x)
  55. var bar = Bar[int]()
  56. bar.test()