From 9fa69d222fe3175c59060164a41f2ed1b020080c Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Thu, 5 Feb 2026 12:41:54 +0800 Subject: [PATCH] fixes #25482; ICE leaking temporary 3 slotTempInt (#25483) fixes #25482 (cherry picked from commit a04f720217f3d7c34506bc85e91c9e47ef3873fa) --- compiler/vmgen.nim | 2 ++ tests/vm/tvmmisc.nim | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index 8deb3048e4..9ea0b6ef74 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -803,6 +803,8 @@ proc genNarrow(c: PCtx; n: PNode; dest: TDest) = let first = c.genx(newIntTypeNode(firstOrd(c.config, t), intType)) let last = c.genx(newIntTypeNode(lastOrd(c.config, t), intType)) c.gABC(n, opcNarrowR, dest, first, last) + c.freeTemp(first) + c.freeTemp(last) proc genNarrowU(c: PCtx; n: PNode; dest: TDest) = let t = skipTypes(n.typ, abstractVar-{tyTypeDesc}) diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim index e2d979fad6..35ac6f0ccf 100644 --- a/tests/vm/tvmmisc.nim +++ b/tests/vm/tvmmisc.nim @@ -821,3 +821,10 @@ proc g1314(_: static bool) = discard proc g1314(_: int) = discard proc y1314() = g1314((; let k = 0; k)) y1314() + +proc myProc(first: range[0..100]) = + var x = first + while x > 0: + dec(x) + +const r = (myProc(3); 1)