t3330.nim 1.6 KB

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