summary refs log tree commit diff stats
path: root/tests/destructor/tconsume_twice.nim
blob: 8687b3ce548d66897b18c744c2b997e8c4ffc5e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
discard """
  cmd: "nim c --newruntime $file"
  errormsg: "sink parameter `a` is already consumed at tconsume_twice.nim(11, 10)"
  line: 13
"""
type
  Foo = ref object

proc use(a: owned Foo): bool = discard
proc consumeTwice(a: owned Foo): owned Foo =
  if use(a):
    return
  return a

assert consumeTwice(Foo()) != nil