mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
fixes #22218
This commit is contained in:
@@ -985,7 +985,9 @@ proc computeCursors*(s: PSym; n: PNode; g: ModuleGraph) =
|
||||
if v.flags * {ownsData, preventCursor, isConditionallyReassigned} == {} and
|
||||
v.sym.kind notin {skParam, skResult} and
|
||||
v.sym.flags * {sfThread, sfGlobal} == {} and hasDestructor(v.sym.typ) and
|
||||
v.sym.typ.skipTypes({tyGenericInst, tyAlias}).kind != tyOwned:
|
||||
v.sym.typ.skipTypes({tyGenericInst, tyAlias}).kind != tyOwned and
|
||||
(getAttachedOp(g, v.sym.typ, attachedAsgn) == nil or
|
||||
sfError notin getAttachedOp(g, v.sym.typ, attachedAsgn).flags):
|
||||
let rid = root(par, i)
|
||||
if par.s[rid].con.kind == isRootOf and dangerousMutation(par.graphs[par.s[rid].con.graphIndex], par.s[i]):
|
||||
discard "cannot cursor into a graph that is mutated"
|
||||
|
||||
25
tests/arc/t22218.nim
Normal file
25
tests/arc/t22218.nim
Normal file
@@ -0,0 +1,25 @@
|
||||
discard """
|
||||
cmd: "nim c --mm:arc $file"
|
||||
errormsg: "'=copy' is not available for type <Obj>; requires a copy because it's not the last read of 'chan[]'; routine: test"
|
||||
"""
|
||||
|
||||
# bug #22218
|
||||
type Obj[T] = object
|
||||
v: T
|
||||
|
||||
proc `=copy`[T](
|
||||
dest: var Obj[T],
|
||||
source: Obj[T]
|
||||
) {.error: "A channel cannot be copied".}
|
||||
|
||||
from system/ansi_c import c_calloc
|
||||
|
||||
proc test() =
|
||||
var v: bool = true
|
||||
var chan = cast[ptr Obj[int]](c_calloc(1, csize_t sizeof(Obj[int])))
|
||||
var copy = chan[]
|
||||
|
||||
echo chan.v
|
||||
echo v
|
||||
|
||||
test()
|
||||
Reference in New Issue
Block a user