summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-09-20 11:37:54 +0200
committerGitHub <noreply@github.com>2021-09-20 11:37:54 +0200
commit14ced06bb1ef7f23fc6391d16763f1421a3edc80 (patch)
tree62a28895c1c15c743ee1b9dad1ae8e629549bb60
parentee9795f76f1125e0addbf8cf5471cf188ad7f57a (diff)
downloadNim-14ced06bb1ef7f23fc6391d16763f1421a3edc80.tar.gz
fixes #18863 [backport] (#18871)
-rw-r--r--compiler/semstmts.nim2
-rw-r--r--compiler/semtempl.nim7
2 files changed, 5 insertions, 4 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index c2f05ccce..81d6eeda2 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -1905,7 +1905,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
 
   if tfTriggersCompileTime in s.typ.flags: incl(s.flags, sfCompileTime)
   if n[patternPos].kind != nkEmpty:
-    n[patternPos] = semPattern(c, n[patternPos])
+    n[patternPos] = semPattern(c, n[patternPos], s)
   if s.kind == skIterator:
     s.typ.flags.incl(tfIterator)
   elif s.kind == skFunc:
diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim
index 2636784af..eda4ca6cc 100644
--- a/compiler/semtempl.nim
+++ b/compiler/semtempl.nim
@@ -334,7 +334,7 @@ proc semTemplSomeDecl(c: var TemplCtx, n: PNode, symKind: TSymKind; start = 0) =
       illFormedAst(a, c.c.config)
 
 
-proc semPattern(c: PContext, n: PNode): PNode
+proc semPattern(c: PContext, n: PNode; s: PSym): PNode
 
 proc semTemplBodySons(c: var TemplCtx, n: PNode): PNode =
   result = n
@@ -645,7 +645,7 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
   if allUntyped: incl(s.flags, sfAllUntyped)
 
   if n[patternPos].kind != nkEmpty:
-    n[patternPos] = semPattern(c, n[patternPos])
+    n[patternPos] = semPattern(c, n[patternPos], s)
 
   var ctx: TemplCtx
   ctx.toBind = initIntSet()
@@ -798,7 +798,7 @@ proc semPatternBody(c: var TemplCtx, n: PNode): PNode =
     for i in 0..<n.len:
       result[i] = semPatternBody(c, n[i])
 
-proc semPattern(c: PContext, n: PNode): PNode =
+proc semPattern(c: PContext, n: PNode; s: PSym): PNode =
   openScope(c)
   var ctx: TemplCtx
   ctx.toBind = initIntSet()
@@ -813,3 +813,4 @@ proc semPattern(c: PContext, n: PNode): PNode =
     elif result.len == 0:
       localError(c.config, n.info, "a pattern cannot be empty")
   closeScope(c)
+  addPattern(c, LazySym(sym: s))