diff options
author | metagn <10591326+metagn@users.noreply.github.com> | 2022-07-15 13:37:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-15 12:37:08 +0200 |
commit | f35c9cf73ddb3150ab6dbe449db4975866ee8a11 (patch) | |
tree | fd09374ec0a1efb82397f366aab1256079b44aa5 | |
parent | 286fcef68ef6f0e3a20ab5b25307c9b4705ce54d (diff) | |
download | Nim-f35c9cf73ddb3150ab6dbe449db4975866ee8a11.tar.gz |
fix #20002 (#20004)
While this fix seems innocent, this unlocks the hidden behavior of method calls not being able to call gensym'ed routines inside templates.
-rw-r--r-- | compiler/semtempl.nim | 2 | ||||
-rw-r--r-- | tests/template/tinnerouterproc.nim | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index a599edb9c..1f76aff75 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -78,7 +78,7 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule; result = newNodeIT(kind, info, newTypeS(tyNone, c)) a = initOverloadIter(o, c, n) while a != nil: - if a.kind != skModule and (not isField or sfGenSym notin s.flags): + if a.kind != skModule and (not isField or sfGenSym notin a.flags): incl(a.flags, sfUsed) markOwnerModuleAsUsed(c, a) result.add newSymNode(a, info) diff --git a/tests/template/tinnerouterproc.nim b/tests/template/tinnerouterproc.nim new file mode 100644 index 000000000..1f15fb13e --- /dev/null +++ b/tests/template/tinnerouterproc.nim @@ -0,0 +1,8 @@ +block: # #20002 + proc bar(x: int): int = 10 + template foo = + proc bar(x: int): int {.gensym.} = x + 2 + doAssert bar(3) == 5 + discard 3.bar # evaluates to 10 but only check if it compiles for now + block: + foo() |