mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-11 22:08:54 +00:00
effects: exclude swap() from "indirect calls" assumption (#15504)
swap() will never call any procs passed to it, and so it can be safely excluded from the "assume indirect calls are taken" effects tracking rule.
This commit is contained in:
@@ -552,7 +552,7 @@ proc isNoEffectList(n: PNode): bool {.inline.} =
|
||||
n.len == 0 or (n[tagEffects] == nil and n[exceptionEffects] == nil)
|
||||
|
||||
proc isTrival(caller: PNode): bool {.inline.} =
|
||||
result = caller.kind == nkSym and caller.sym.magic in {mEqProc, mIsNil, mMove, mWasMoved}
|
||||
result = caller.kind == nkSym and caller.sym.magic in {mEqProc, mIsNil, mMove, mWasMoved, mSwap}
|
||||
|
||||
proc trackOperandForIndirectCall(tracked: PEffects, n: PNode, paramType: PType; caller: PNode) =
|
||||
let a = skipConvAndClosure(n)
|
||||
|
||||
12
tests/effects/teffects10.nim
Normal file
12
tests/effects/teffects10.nim
Normal file
@@ -0,0 +1,12 @@
|
||||
discard """
|
||||
action: compile
|
||||
"""
|
||||
|
||||
# https://github.com/nim-lang/Nim/issues/15495
|
||||
|
||||
proc f() {.raises: [].} =
|
||||
var a: proc ()
|
||||
var b: proc ()
|
||||
swap(a, b)
|
||||
|
||||
f()
|
||||
Reference in New Issue
Block a user