summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2024-09-06 12:16:43 +0300
committerGitHub <noreply@github.com>2024-09-06 11:16:43 +0200
commitbf865fa75aba5ed61f123e528044285a87bdd0b1 (patch)
tree66b72d7a35e0fe8125e3e89a7e9baf5f2884f5e8 /compiler
parentd91297a330a4cccc4d82c06d4c33b16544b0c1bb (diff)
downloadNim-bf865fa75aba5ed61f123e528044285a87bdd0b1.tar.gz
fix undeclared identifier in templates in generics (#24069)
fixes #13979

Fixes templates in generics that use identifiers that aren't defined
yet, giving an early `undeclared identifier` error, by just marking
template bodies as in a mixin context in `semgnrc`.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semgnrc.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim
index e3a8daf99..16bb7f094 100644
--- a/compiler/semgnrc.nim
+++ b/compiler/semgnrc.nim
@@ -613,7 +613,8 @@ proc semGenericStmt(c: PContext, n: PNode,
       else:
         body = getBody(c.graph, s)
     else: body = n[bodyPos]
-    n[bodyPos] = semGenericStmtScope(c, body, flags, ctx)
+    let bodyFlags = if n.kind == nkTemplateDef: flags + {withinMixin} else: flags
+    n[bodyPos] = semGenericStmtScope(c, body, bodyFlags, ctx)
     closeScope(c)
   of nkPragma, nkPragmaExpr: discard
   of nkExprColonExpr, nkExprEqExpr: