tinvalidborrow.nim 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. discard """
  2. cmd: "nim check --hints:off --warnings:off $file"
  3. action: "reject"
  4. nimout:'''
  5. tinvalidborrow.nim(25, 3) Error: only a 'distinct' type can borrow `.`
  6. tinvalidborrow.nim(26, 3) Error: only a 'distinct' type can borrow `.`
  7. tinvalidborrow.nim(27, 1) Error: borrow proc without distinct type parameter is meaningless
  8. tinvalidborrow.nim(36, 1) Error: borrow with generic parameter is not supported
  9. tinvalidborrow.nim(41, 1) Error: borrow from proc return type mismatch: 'T'
  10. tinvalidborrow.nim(42, 1) Error: borrow from '[]=' is not supported
  11. '''
  12. """
  13. # bug #516
  14. type
  15. TAtom = culong
  16. Test {.borrow:`.`.} = distinct int
  17. Foo[T] = object
  18. a: int
  19. Bar[T] {.borrow:`.`.} = Foo[T]
  20. OtherFoo {.borrow:`.`.} = Foo[int]
  21. proc `==`*(a, b: TAtom): bool {.borrow.}
  22. var
  23. d, e: TAtom
  24. discard( $(d == e) )
  25. # issue #4121
  26. type HeapQueue[T] = distinct seq[T]
  27. proc len*[T](h: HeapQueue[T]): int {.borrow.}
  28. # issue #3564
  29. type vec4[T] = distinct array[4, float32]
  30. proc `[]`(v: vec4, i: int): float32 {.borrow.}
  31. proc `[]=`(v: vec4, i: int, va: float32) {.borrow.}