Skip to content

Commit eef2948

Browse files
authored
Fix #12595 (#16874)
1 parent 111092e commit eef2948

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

compiler/semtempl.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,10 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
555555
result[1] = semTemplBody(c, n[1])
556556
else:
557557
result = semTemplBodySons(c, n)
558+
of nkTableConstr:
559+
# also transform the keys (bug #12595)
560+
for i in 0..<n.len:
561+
result[i] = semTemplBodySons(c, n[i])
558562
else:
559563
result = semTemplBodySons(c, n)
560564

tests/template/template_issues.nim

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ discard foo()
256256
type
257257
IteratorF*[In] = iterator() : In {.closure.}
258258

259-
template foof(In: untyped) : untyped =
259+
template foof(In: untyped) : untyped =
260260
proc ggg*(arg: IteratorF[In]) =
261261
for i in arg():
262262
echo "foo"
@@ -265,7 +265,7 @@ template foof(In: untyped) : untyped =
265265
iterator hello() : int {.closure.} =
266266
for i in 1 .. 3:
267267
yield i
268-
268+
269269
foof(int)
270270
ggg(hello)
271271

@@ -290,3 +290,9 @@ proc bar(t: var int) =
290290

291291
foo(bar)
292292

293+
block: # bug #12595
294+
template test() =
295+
let i = 42
296+
discard {i: ""}
297+
298+
test()

0 commit comments

Comments
 (0)