summary refs log tree commit diff stats
path: root/tests/borrow/tinvalidborrow.nim
blob: 08148608d6c8973f0520300bd3835126432c6af4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
discard """
  cmd: "nim check --hints:off --warnings:off $file"
  action: "reject"
  nimout:'''
tinvalidborrow.nim(18, 3) Error: only a 'distinct' type can borrow `.`
tinvalidborrow.nim(19, 3) Error: only a 'distinct' type can borrow `.`
tinvalidborrow.nim(20, 1) Error: no symbol to borrow from found
'''
"""

# bug #516

type
  TAtom = culong
  Test {.borrow:`.`.} = distinct int
  Foo[T] = object
    a: int
  Bar[T] {.borrow:`.`.} = Foo[T]
  OtherFoo {.borrow:`.`.} = Foo[int]
proc `==`*(a, b: TAtom): bool {.borrow.}

var
  d, e: TAtom

discard( $(d == e) )