Skip to content

Commit 1cbdc15

Browse files
authored
fixes #19159 [backport:1.6] (#19210)
1 parent f90620f commit 1cbdc15

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

compiler/sempass2.nim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,13 +852,14 @@ proc trackCall(tracked: PEffects; n: PNode) =
852852
assumeTheWorst(tracked, n, op)
853853
gcsafeAndSideeffectCheck()
854854
else:
855-
if strictEffects in tracked.c.features and a.kind == nkSym and a.sym.kind in routineKinds:
855+
if strictEffects in tracked.c.features and a.kind == nkSym and
856+
a.sym.kind in routineKinds:
856857
propagateEffects(tracked, n, a.sym)
857858
else:
858859
mergeRaises(tracked, effectList[exceptionEffects], n)
859860
mergeTags(tracked, effectList[tagEffects], n)
860861
gcsafeAndSideeffectCheck()
861-
if a.kind != nkSym or a.sym.magic notin {mNBindSym, mFinished}:
862+
if a.kind != nkSym or a.sym.magic notin {mNBindSym, mFinished, mExpandToAst, mQuoteAst}:
862863
for i in 1..<n.len:
863864
trackOperandForIndirectCall(tracked, n[i], op, i, a)
864865
if a.kind == nkSym and a.sym.magic in {mNew, mNewFinalize, mNewSeq}:
@@ -883,7 +884,7 @@ proc trackCall(tracked: PEffects; n: PNode) =
883884
optStaticBoundsCheck in tracked.currOptions:
884885
checkBounds(tracked, n[1], n[2])
885886

886-
if a.kind != nkSym or a.sym.magic != mRunnableExamples:
887+
if a.kind != nkSym or a.sym.magic notin {mRunnableExamples, mNBindSym, mExpandToAst, mQuoteAst}:
887888
for i in 0..<n.safeLen:
888889
track(tracked, n[i])
889890

tests/effects/tstrict_effects3.nim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,15 @@ proc fn(a: int, p1, p2: proc()) {.effectsOf: p1.} =
1515
proc main() {.raises: [ValueError].} =
1616
fn(1, proc()=discard, proc() = raise newException(IOError, "foo"))
1717
main()
18+
19+
# bug #19159
20+
21+
import macros
22+
23+
func mkEnter() =
24+
template helper =
25+
discard
26+
when defined pass:
27+
helper()
28+
else:
29+
let ast = getAst(helper())

0 commit comments

Comments
 (0)