t3330.nim 1.7 KB

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