mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-30 19:23:57 +00:00
* Assign hook name changed to `=copy` * Adapt destructors.rst * [nobackport] Duplicate tests for =copy hook * Fix tests * added a changelog entry Co-authored-by: Clyybber <darkmine956@gmail.com>
16 lines
433 B
Nim
16 lines
433 B
Nim
discard """
|
|
cmd: "nim c --newruntime $file"
|
|
errormsg: "'=copy' is not available for type <owned Foo>; requires a copy because it's not the last read of 'a'; another read is done here: tconsume_twice.nim(13, 10); routine: consumeTwice"
|
|
line: 11
|
|
"""
|
|
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
|