diff options
author | konsumlamm <44230978+konsumlamm@users.noreply.github.com> | 2021-01-31 01:00:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-31 01:00:18 +0100 |
commit | eef2948ec2725d69358ab647a25bfa4ac675ed91 (patch) | |
tree | af190dca7804330bbee41468d42e531ae0b1b79b | |
parent | 111092e8aa4817c5a62a2da95bdf0b487c21f8fb (diff) | |
download | Nim-eef2948ec2725d69358ab647a25bfa4ac675ed91.tar.gz |
Fix #12595 (#16874)
-rw-r--r-- | compiler/semtempl.nim | 4 | ||||
-rw-r--r-- | tests/template/template_issues.nim | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index 65dc95916..1e6cd88b7 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -555,6 +555,10 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode = result[1] = semTemplBody(c, n[1]) else: result = semTemplBodySons(c, n) + of nkTableConstr: + # also transform the keys (bug #12595) + for i in 0..<n.len: + result[i] = semTemplBodySons(c, n[i]) else: result = semTemplBodySons(c, n) diff --git a/tests/template/template_issues.nim b/tests/template/template_issues.nim index b4b056da5..502c6d1ee 100644 --- a/tests/template/template_issues.nim +++ b/tests/template/template_issues.nim @@ -256,7 +256,7 @@ discard foo() type IteratorF*[In] = iterator() : In {.closure.} -template foof(In: untyped) : untyped = +template foof(In: untyped) : untyped = proc ggg*(arg: IteratorF[In]) = for i in arg(): echo "foo" @@ -265,7 +265,7 @@ template foof(In: untyped) : untyped = iterator hello() : int {.closure.} = for i in 1 .. 3: yield i - + foof(int) ggg(hello) @@ -290,3 +290,9 @@ proc bar(t: var int) = foo(bar) +block: # bug #12595 + template test() = + let i = 42 + discard {i: ""} + + test() |