summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-09-14 15:47:37 +0200
committerAraq <rumpf_a@web.de>2018-09-14 15:47:37 +0200
commit5ee904643af3c5bf126121cd9534ddcb11cd4630 (patch)
tree6e29b631d5b25380a5488d74cdca851502164787 /compiler
parent4ab99537875a763e0540fbbe48d69cad454ca792 (diff)
downloadNim-5ee904643af3c5bf126121cd9534ddcb11cd4630.tar.gz
fixes #8883
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semtypinst.nim7
-rw-r--r--compiler/sighashes.nim10
2 files changed, 12 insertions, 5 deletions
diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim
index c315cbebb..a6067dfc9 100644
--- a/compiler/semtypinst.nim
+++ b/compiler/semtypinst.nim
@@ -367,8 +367,11 @@ proc handleGenericInvocation(cl: var TReplTypeVars, t: PType): PType =
         # can come here for tyGenericInst too, see tests/metatype/ttypeor.nim
         # need to look into this issue later
         assert newbody.kind in {tyRef, tyPtr}
-        assert newbody.lastSon.typeInst == nil
-        newbody.lastSon.typeInst = result
+        if newbody.lastSon.typeInst != nil:
+          #internalError(cl.c.config, cl.info, "ref already has a 'typeInst' field")
+          discard
+        else:
+          newbody.lastSon.typeInst = result
     cl.c.typesWithOps.add((newbody, result))
     let methods = skipTypes(bbody, abstractPtrs).methods
     for col, meth in items(methods):
diff --git a/compiler/sighashes.nim b/compiler/sighashes.nim
index 8f95175e5..222a0d66e 100644
--- a/compiler/sighashes.nim
+++ b/compiler/sighashes.nim
@@ -173,9 +173,13 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
       c.hashSym(t.sym)
   of tyObject, tyEnum:
     if t.typeInst != nil:
-      assert t.typeInst.kind == tyGenericInst
-      for i in countup(0, sonsLen(t.typeInst) - 2):
-        c.hashType t.typeInst.sons[i], flags
+      # prevent against infinite recursions here, see bug #8883:
+      let inst = t.typeInst
+      t.typeInst = nil
+      assert inst.kind == tyGenericInst
+      for i in countup(0, inst.len - 2):
+        c.hashType inst.sons[i], flags
+      t.typeInst = inst
       return
     c &= char(t.kind)
     # Every cyclic type in Nim need to be constructed via some 't.sym', so this