mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-11 03:39:31 +00:00
Improve effect propagation by skipping hooks in trackCall (#25940)
ref https://github.com/nim-lang/Nim/pull/25731 don't propagate effects for assignment hooks without effect lists
This commit is contained in:
@@ -1197,7 +1197,9 @@ proc trackCall(tracked: PEffects; n: PNode) =
|
||||
else:
|
||||
if laxEffects notin tracked.c.config.legacyFeatures and a.kind == nkSym and
|
||||
a.sym.kind in routineKinds:
|
||||
propagateEffects(tracked, n, a.sym)
|
||||
let (isHook, opKind) = findHookKind(a.sym.name.s)
|
||||
if (not isHook) or opKind notin {attachedAsgn, attachedSink, attachedDup}:
|
||||
propagateEffects(tracked, n, a.sym)
|
||||
else:
|
||||
mergeRaises(tracked, effectList[exceptionEffects], n)
|
||||
mergeTags(tracked, effectList[tagEffects], n)
|
||||
|
||||
@@ -13,4 +13,12 @@ proc send(x: string) =
|
||||
let wrapper = Thing(x: x)
|
||||
discard isolate(wrapper)
|
||||
|
||||
send("la")
|
||||
send("la")
|
||||
|
||||
block:
|
||||
func enqueue[T](buf: var array[10, T], elem: sink T) =
|
||||
`=sink`(buf[0], elem)
|
||||
|
||||
var buf: array[10, int]
|
||||
enqueue(buf, 42)
|
||||
assert buf[0] == 42
|
||||
Reference in New Issue
Block a user