From eeed26f6b2ab606577739bf73d4b63f1442beca3 Mon Sep 17 00:00:00 2001 From: hlaaftana <10591326+metagn@users.noreply.github.com> Date: Wed, 7 Sep 2022 12:41:31 +0300 Subject: [PATCH] fix #13515 --- compiler/semtempl.nim | 1 + tests/template/t13515.nim | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 tests/template/t13515.nim diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index 6b71892a0d82..cdebf1f46edf 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -269,6 +269,7 @@ proc semTemplSymbol(c: PContext, n: PNode, s: PSym; isField: bool): PNode = # field access (dot expr) will be handled by builtinFieldAccess if not isField: styleCheckUse(c, n.info, s) + result.typ = nil # for typ.isNil checks that sem this node again proc semRoutineInTemplName(c: var TemplCtx, n: PNode): PNode = result = n diff --git a/tests/template/t13515.nim b/tests/template/t13515.nim new file mode 100644 index 000000000000..47cb529f2ef9 --- /dev/null +++ b/tests/template/t13515.nim @@ -0,0 +1,12 @@ +template test: bool = true + +# compiles: +if not test: + echo "wtf" + +# does not compile: +template x = + if not test: + echo "wtf" + +x