mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-01 13:09:14 +00:00
fixes #26010 Cursors do not own their values and therefore cannot transfer ownership through move. Reject move(cursor) during semantic analysis and share the cursor-location check between semantic analysis and destructor injection.
24 lines
408 B
Nim
24 lines
408 B
Nim
discard """
|
|
action: reject
|
|
matrix: "--mm:orc; --mm:refc"
|
|
errormsg: "cannot move cursor 'a'; a cursor does not own its value"
|
|
"""
|
|
|
|
# bug #26010: a cursor is a non-owning alias and cannot transfer ownership.
|
|
|
|
type Xxx = object
|
|
|
|
proc `=destroy`(v: var Xxx) =
|
|
debugEcho "dest"
|
|
|
|
proc test(v: ref Xxx) =
|
|
var a {.cursor.} = v
|
|
var b = move(a)
|
|
discard
|
|
|
|
proc main() =
|
|
var x = new Xxx
|
|
test(x)
|
|
|
|
main()
|