From 4cf26582359a127c4e99a2116347aedfa6573e33 Mon Sep 17 00:00:00 2001 From: SirOlaf <34164198+SirOlaf@users.noreply.github.com> Date: Wed, 23 Aug 2023 06:18:35 +0200 Subject: [PATCH] Fix #21532: Check if template return is untyped (#22517) * Don't ignore return in semTemplateDef * Add test --------- Co-authored-by: SirOlaf <> (cherry picked from commit 3de75ffc02ea85b95702ec0dc0976748954d3e2c) --- compiler/semtempl.nim | 3 +++ tests/template/t21532.nim | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 tests/template/t21532.nim diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index f63b0a7d0c..e2095d4916 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -673,6 +673,9 @@ proc semTemplateDef(c: PContext, n: PNode): PNode = # a template's parameters are not gensym'ed even if that was originally the # case as we determine whether it's a template parameter in the template # body by the absence of the sfGenSym flag: + let retType = s.typ[0] + if retType != nil and retType.kind != tyUntyped: + allUntyped = false for i in 1..