summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/transf.nim2
-rw-r--r--tests/iter/t22148.nim15
2 files changed, 16 insertions, 1 deletions
diff --git a/compiler/transf.nim b/compiler/transf.nim
index 0a28fd1a0..6ff1da899 100644
--- a/compiler/transf.nim
+++ b/compiler/transf.nim
@@ -326,7 +326,7 @@ proc introduceNewLocalVars(c: PTransf, n: PNode): PNode =
     return n
   of nkProcDef: # todo optimize nosideeffects?
     result = newTransNode(n)
-    let x = freshVar(c, n[namePos].sym)
+    let x = newSymNode(copySym(n[namePos].sym, c.idgen))
     idNodeTablePut(c.transCon.mapping, n[namePos].sym, x)
     result[namePos] = x # we have to copy proc definitions for iters
     for i in 1..<n.len:
diff --git a/tests/iter/t22148.nim b/tests/iter/t22148.nim
new file mode 100644
index 000000000..9954eed87
--- /dev/null
+++ b/tests/iter/t22148.nim
@@ -0,0 +1,15 @@
+discard """

+  action: compile

+"""

+

+import std/memfiles

+

+# bug #22148

+proc make*(input: string) =

+  var inp = memfiles.open(input)

+  for line in memSlices(inp):

+    let lineF = MemFile(mem: line.data, size: line.size)

+    for word in memSlices(lineF, ','):

+      discard

+

+make("") # Must call to trigger