summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-09-11 09:57:33 +0200
committerAraq <rumpf_a@web.de>2014-09-11 09:57:33 +0200
commitff55c487b6b550229b6ca3064c0d432134ca3fff (patch)
treee289d7159ae62cf9d14ea9503c4ac5cbc617706b
parent46bbae47455f5cefdec78251d8078ae07014bef6 (diff)
downloadNim-ff55c487b6b550229b6ca3064c0d432134ca3fff.tar.gz
mostly fixes #1339
-rw-r--r--compiler/semtypinst.nim8
-rw-r--r--compiler/types.nim4
2 files changed, 9 insertions, 3 deletions
diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim
index eeaf53649..9f0a4100d 100644
--- a/compiler/semtypinst.nim
+++ b/compiler/semtypinst.nim
@@ -216,12 +216,16 @@ proc replaceTypeVarsS(cl: var TReplTypeVars, s: PSym): PSym =
     result.typ = replaceTypeVarsT(cl, s.typ)
     result.ast = replaceTypeVarsN(cl, s.ast)
     
-proc lookupTypeVar(cl: TReplTypeVars, t: PType): PType = 
+proc lookupTypeVar(cl: var TReplTypeVars, t: PType): PType = 
   result = PType(idTableGet(cl.typeMap, t))
   if result == nil:
     if cl.allowMetaTypes or tfRetType in t.flags: return
     localError(t.sym.info, errCannotInstantiateX, typeToString(t))
     result = errorType(cl.c)
+    # In order to prevent endless recursions, we must remember
+    # this bad lookup and replace it with errorType everywhere.
+    # These code paths are only active in nimrod check
+    idTablePut(cl.typeMap, t, result)
   elif result.kind == tyGenericParam and not cl.allowMetaTypes:
     internalError(cl.info, "substitution with generic parameter")
 
@@ -353,7 +357,7 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
 
   of tyGenericBody:
     localError(cl.info, errCannotInstantiateX, typeToString(t))
-    result = t
+    result = errorType(cl.c)
     #result = replaceTypeVarsT(cl, lastSon(t))
 
   of tyFromExpr:
diff --git a/compiler/types.nim b/compiler/types.nim
index ec2271deb..c04413857 100644
--- a/compiler/types.nim
+++ b/compiler/types.nim
@@ -913,9 +913,11 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
           result = sameTypeAux(a.sons[0], b.sons[0], c)     
     else: 
       result = sameTypeAux(a.sons[0], b.sons[0], c) and sameFlags(a, b)
-  of tyEnum, tyForward, tyProxy:
+  of tyEnum, tyForward:
     # XXX generic enums do not make much sense, but require structural checking
     result = a.id == b.id and sameFlags(a, b)
+  of tyError:
+    result = b.kind == tyError
   of tyTuple:
     cycleCheck()
     result = sameTuple(a, b, c) and sameFlags(a, b)