maybe now

This commit is contained in:
Araq
2026-02-21 23:29:49 +01:00
parent c30948e57d
commit b146154028

View File

@@ -1286,24 +1286,15 @@ proc produceSym(g: ModuleGraph; c: PContext; typ: PType; kind: TTypeAttachedOp;
tk = tyNone # no special casing for strings and seqs
case tk
of tySequence:
fillSeqOp(a, typ, result.ast[bodyPos], d, src)
# YRC: topology-changing seq ops must hold the mutator (read) lock
if g.config.selectedGC == gcYrc and
let needsYrcLock = g.config.selectedGC == gcYrc and
kind in {attachedDestructor, attachedSink, attachedAsgn, attachedDeepCopy, attachedDup} and
types.canFormAcycle(g, skipped.elementType):
let acquireSym = getSysSym(g, info, "acquireMutatorLock")
let releaseSym = getSysSym(g, info, "releaseMutatorLock")
if acquireSym != nil and releaseSym != nil and acquireSym.kind != skError and releaseSym.kind != skError:
let acquireCall = newNodeI(nkCall, info)
acquireCall.add newSymNode(acquireSym)
let releaseCall = newNodeI(nkCall, info)
releaseCall.add newSymNode(releaseSym)
let oldBody = result.ast[bodyPos]
result.ast[bodyPos] = newTree(nkStmtList,
acquireCall,
newTree(nkTryStmt,
oldBody,
newTree(nkFinally, newTree(nkStmtList, releaseCall))))
types.canFormAcycle(g, skipped.elementType)
# YRC: topology-changing seq ops must hold the mutator (read) lock
if needsYrcLock:
result.ast[bodyPos].add callCodegenProc(g, "acquireMutatorLock", info)
fillSeqOp(a, typ, result.ast[bodyPos], d, src)
if needsYrcLock:
result.ast[bodyPos].add callCodegenProc(g, "releaseMutatorLock", info)
of tyString:
fillStrOp(a, typ, result.ast[bodyPos], d, src)
else: