mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-02 13:39:03 +00:00
fixes #26023; incorrect sink requires a copy
This commit is contained in:
@@ -606,10 +606,16 @@ proc setHookDisamb*(g: ModuleGraph; hook: PSym; opName: string; typ: PType) =
|
||||
break
|
||||
hook.disamb = h
|
||||
|
||||
proc hasDisabledAsgn*(g: ModuleGraph; t: PType): bool =
|
||||
let op = getAttachedOp(g, t, attachedAsgn)
|
||||
proc hasDisabledOp(g: ModuleGraph; t: PType; kind: TTypeAttachedOp): bool =
|
||||
let op = getAttachedOp(g, t, kind)
|
||||
result = op != nil and sfError in op.flags
|
||||
|
||||
proc hasDisabledAsgn*(g: ModuleGraph; t: PType): bool =
|
||||
result = hasDisabledOp(g, t, attachedAsgn)
|
||||
|
||||
proc hasDisabledDup*(g: ModuleGraph; t: PType): bool =
|
||||
result = hasDisabledOp(g, t, attachedDup)
|
||||
|
||||
proc copyTypeProps*(g: ModuleGraph; module: int; dest, src: PType) =
|
||||
for k in low(TTypeAttachedOp)..high(TTypeAttachedOp):
|
||||
let op = getAttachedOp(g, src, k)
|
||||
|
||||
@@ -1024,8 +1024,8 @@ proc computeCursors*(s: PSym; n: PNode; g: ModuleGraph) =
|
||||
v.sym.flags * {sfThread, sfGlobal} == {} and
|
||||
(hasDestructor(v.sym.typ) or (jsCursors and jsDeepCopied(v.sym.typ))) and
|
||||
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):
|
||||
not hasDisabledAsgn(g, v.sym.typ) and
|
||||
not hasDisabledDup(g, v.sym.typ):
|
||||
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"
|
||||
|
||||
@@ -65,3 +65,17 @@ method handleConn*(myParam: PubSub,
|
||||
proto: string) {.base, async.} =
|
||||
myParam.peers.withValue(conn.peerInfo.peerId, peer):
|
||||
let peerB = peer[]
|
||||
|
||||
|
||||
|
||||
block:
|
||||
type M = object
|
||||
|
||||
proc `=dup`(_: M): M {.error.}
|
||||
proc take(_: sink M) = discard
|
||||
|
||||
proc test() =
|
||||
var value: M
|
||||
take(value)
|
||||
|
||||
test()
|
||||
|
||||
Reference in New Issue
Block a user