summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/astalgo.nim16
-rw-r--r--compiler/sem.nim1
-rw-r--r--compiler/semcall.nim1
-rw-r--r--tests/template/tgenerictemplates.nim24
4 files changed, 34 insertions, 8 deletions
diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim
index d98a42b34..15072e175 100644
--- a/compiler/astalgo.nim
+++ b/compiler/astalgo.nim
@@ -69,22 +69,22 @@ proc debug*(n: PNode) {.deprecated.}
 
 template mdbg*: bool {.dirty.} =
   when compiles(c.module):
-    c.module.fileIdx.int32 == gProjectMainIdx
+    c.module.fileIdx.int32 == c.config.projectMainIdx
   elif compiles(c.c.module):
-    c.c.module.fileIdx.int32 == gProjectMainIdx
+    c.c.module.fileIdx.int32 == c.c.config.projectMainIdx
   elif compiles(m.c.module):
-    m.c.module.fileIdx.int32 == gProjectMainIdx
+    m.c.module.fileIdx.int32 == m.c.config.projectMainIdx
   elif compiles(cl.c.module):
-    cl.c.module.fileIdx.int32 == gProjectMainIdx
+    cl.c.module.fileIdx.int32 == cl.c.config.projectMainIdx
   elif compiles(p):
     when compiles(p.lex):
-      p.lex.fileIdx.int32 == gProjectMainIdx
+      p.lex.fileIdx.int32 == p.lex.config.projectMainIdx
     else:
-      p.module.module.fileIdx.int32 == gProjectMainIdx
+      p.module.module.fileIdx.int32 == p.config.projectMainIdx
   elif compiles(m.module.fileIdx):
-    m.module.fileIdx.int32 == gProjectMainIdx
+    m.module.fileIdx.int32 == m.config.projectMainIdx
   elif compiles(L.fileIdx):
-    L.fileIdx.int32 == gProjectMainIdx
+    L.fileIdx.int32 == L.config.projectMainIdx
   else:
     error()
 
diff --git a/compiler/sem.nim b/compiler/sem.nim
index c5c3dd99b..7bccf1556 100644
--- a/compiler/sem.nim
+++ b/compiler/sem.nim
@@ -38,6 +38,7 @@ proc changeType(c: PContext; n: PNode, newType: PType, check: bool)
 proc semLambda(c: PContext, n: PNode, flags: TExprFlags): PNode
 proc semTypeNode(c: PContext, n: PNode, prev: PType): PType
 proc semStmt(c: PContext, n: PNode): PNode
+proc semOpAux(c: PContext, n: PNode)
 proc semParamList(c: PContext, n, genericParams: PNode, s: PSym)
 proc addParams(c: PContext, n: PNode, kind: TSymKind)
 proc maybeAddResult(c: PContext, s: PSym, n: PNode)
diff --git a/compiler/semcall.nim b/compiler/semcall.nim
index e9a31d3d6..df99d6c24 100644
--- a/compiler/semcall.nim
+++ b/compiler/semcall.nim
@@ -254,6 +254,7 @@ proc resolveOverloads(c: PContext, n, orig: PNode,
   var f = n.sons[0]
   if f.kind == nkBracketExpr:
     # fill in the bindings:
+    semOpAux(c, f)
     initialBinding = f
     f = f.sons[0]
   else:
diff --git a/tests/template/tgenerictemplates.nim b/tests/template/tgenerictemplates.nim
index 2c83bc0ec..142505b1a 100644
--- a/tests/template/tgenerictemplates.nim
+++ b/tests/template/tgenerictemplates.nim
@@ -11,3 +11,27 @@ template someTemplate[T](): tuple[id: int32, obj: T] =
 
 let ret = someTemplate[SomeObj]()
 
+# https://github.com/nim-lang/Nim/issues/7829
+proc inner*[T](): int =
+  discard
+
+template outer*[A](): untyped =
+  inner[A]()
+
+template outer*[B](x: int): untyped =
+  inner[B]()
+
+var i1 = outer[int]()
+var i2 = outer[int](i1)
+
+# https://github.com/nim-lang/Nim/issues/7883
+template t1[T: int|int64](s: string): T =
+   var t: T
+   t
+
+template t1[T: int|int64](x: int, s: string): T =
+   var t: T
+   t
+
+var i3: int = t1[int]("xx")
+