summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-08-12 08:30:17 +0800
committerGitHub <noreply@github.com>2023-08-12 08:30:17 +0800
commit23f3f9ae2ccb28cd5f9a6feaff92b9d26f4244e8 (patch)
tree15602d2af2b753b6e547627c83b6c9cf8994cfd7 /compiler
parent3f7e1d7daadf4002da1a155d7b98ff7fcca9e2fa (diff)
downloadNim-23f3f9ae2ccb28cd5f9a6feaff92b9d26f4244e8.tar.gz
better initialization patterns for seminst (#22456)
* better initialization patterns for seminst

* Update compiler/seminst.nim

* Update compiler/seminst.nim
Diffstat (limited to 'compiler')
-rw-r--r--compiler/seminst.nim19
1 files changed, 5 insertions, 14 deletions
diff --git a/compiler/seminst.nim b/compiler/seminst.nim
index c7735903e..61480494b 100644
--- a/compiler/seminst.nim
+++ b/compiler/seminst.nim
@@ -29,11 +29,7 @@ proc addObjFieldsToLocalScope(c: PContext; n: PNode) =
   else: discard
 
 proc pushProcCon*(c: PContext; owner: PSym) =
-  var x: PProcCon
-  new(x)
-  x.owner = owner
-  x.next = c.p
-  c.p = x
+  c.p = PProcCon(owner: owner, next: c.p)
 
 const
   errCannotInstantiateX = "cannot instantiate: '$1'"
@@ -172,18 +168,13 @@ proc instGenericContainer(c: PContext, info: TLineInfo, header: PType,
                           allowMetaTypes = false): PType =
   internalAssert c.config, header.kind == tyGenericInvocation
 
-  var
-    cl: TReplTypeVars = default(TReplTypeVars)
+  var cl: TReplTypeVars = TReplTypeVars(symMap: initIdTable(),
+        localCache: initIdTable(), typeMap: LayeredIdTable(),
+        info: info, c: c, allowMetaTypes: allowMetaTypes
+      )
 
-  cl.symMap = initIdTable()
-  cl.localCache = initIdTable()
-  cl.typeMap = LayeredIdTable()
   cl.typeMap.topLayer = initIdTable()
 
-  cl.info = info
-  cl.c = c
-  cl.allowMetaTypes = allowMetaTypes
-
   # We must add all generic params in scope, because the generic body
   # may include tyFromExpr nodes depending on these generic params.
   # XXX: This looks quite similar to the code in matchUserTypeClass,