summary refs log tree commit diff stats
path: root/compiler/semobjconstr.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2023-12-12 16:54:50 +0100
committerGitHub <noreply@github.com>2023-12-12 16:54:50 +0100
commitdb603237c648a796ef7bff77641febd30b3999cd (patch)
tree13e693ac432b1542cab7f2b2bbe1b8c11ca258e0 /compiler/semobjconstr.nim
parent8cc3c774c8925c3d21626d09b41ad352bd898e4a (diff)
downloadNim-db603237c648a796ef7bff77641febd30b3999cd.tar.gz
Types: Refactorings; step 1 (#23055)
Diffstat (limited to 'compiler/semobjconstr.nim')
-rw-r--r--compiler/semobjconstr.nim8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/semobjconstr.nim b/compiler/semobjconstr.nim
index 37c939bcd..ae254f45b 100644
--- a/compiler/semobjconstr.nim
+++ b/compiler/semobjconstr.nim
@@ -415,8 +415,8 @@ proc semConstructTypeAux(c: PContext,
       discard collectMissingFields(c, t.n, constrCtx, result.defaults)
     let base = t[0]
     if base == nil or base.id == t.id or
-      base.kind in {tyRef, tyPtr} and base[0].id == t.id:
-        break
+        base.kind in {tyRef, tyPtr} and base.elementType.id == t.id:
+      break
     t = skipTypes(base, skipPtrs)
     if t.kind != tyObject:
       # XXX: This is not supposed to happen, but apparently
@@ -439,7 +439,7 @@ proc computeRequiresInit(c: PContext, t: PType): bool =
 proc defaultConstructionError(c: PContext, t: PType, info: TLineInfo) =
   var objType = t
   while objType.kind notin {tyObject, tyDistinct}:
-    objType = objType.lastSon
+    objType = objType.last
     assert objType != nil
   if objType.kind == tyObject:
     var constrCtx = initConstrContext(objType, newNodeI(nkObjConstr, info))
@@ -470,7 +470,7 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags; expectedType: PType
 
   t = skipTypes(t, {tyGenericInst, tyAlias, tySink, tyOwned})
   if t.kind == tyRef:
-    t = skipTypes(t[0], {tyGenericInst, tyAlias, tySink, tyOwned})
+    t = skipTypes(t.elementType, {tyGenericInst, tyAlias, tySink, tyOwned})
     if optOwnedRefs in c.config.globalOptions:
       result.typ = makeVarType(c, result.typ, tyOwned)
       # we have to watch out, there are also 'owned proc' types that can be used