summary refs log tree commit diff stats
path: root/compiler/sigmatch.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-09-20 00:56:48 +0200
committerAraq <rumpf_a@web.de>2011-09-20 00:56:48 +0200
commitfd62116f6eb80d1dd3d6cc745d80629ad32dca1a (patch)
treeac5cbd102ffa580e322eda22deeef9298babae4a /compiler/sigmatch.nim
parentdc3ace4f379931f2af4dd4a3cd2a0984a94865af (diff)
downloadNim-fd62116f6eb80d1dd3d6cc745d80629ad32dca1a.tar.gz
bugfixes for generics; new threads implementation still broken
Diffstat (limited to 'compiler/sigmatch.nim')
-rwxr-xr-xcompiler/sigmatch.nim13
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 9acf83a46..1e93385d9 100755
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -137,6 +137,8 @@ proc concreteType(mapping: TIdTable, t: PType): PType =
         # example code that triggers it:
         # proc sort[T](cmp: proc(a, b: T): int = cmp)
       if result.kind != tyGenericParam: break
+  of tyGenericInvokation:
+    assert false
   else: 
     result = t                # Note: empty is valid here
   
@@ -388,8 +390,10 @@ proc typeRel(mapping: var TIdTable, f, a: PType): TTypeRelation =
   of tyGenericInvokation: 
     assert(f.sons[0].kind == tyGenericBody)
     if a.kind == tyGenericInvokation: 
-      InternalError("typeRel: tyGenericInvokation -> tyGenericInvokation")
-    if (a.kind == tyGenericInst): 
+      #InternalError("typeRel: tyGenericInvokation -> tyGenericInvokation")
+      # simply no match for now:
+      nil
+    elif a.kind == tyGenericInst:
       if (f.sons[0].containerID == a.sons[0].containerID) and
           (sonsLen(a) - 1 == sonsLen(f)): 
         assert(a.sons[0].kind == tyGenericBody)
@@ -404,7 +408,7 @@ proc typeRel(mapping: var TIdTable, f, a: PType): TTypeRelation =
         # we steal the generic parameters from the tyGenericBody:
         for i in countup(1, sonsLen(f) - 1):
           var x = PType(idTableGet(mapping, f.sons[0].sons[i - 1]))
-          if x == nil or x.kind == tyGenericParam:
+          if x == nil or x.kind in {tyGenericInvokation, tyGenericParam}:
             InternalError("wrong instantiated type!")
           idTablePut(mapping, f.sons[i], x)
   of tyGenericParam: 
@@ -413,8 +417,7 @@ proc typeRel(mapping: var TIdTable, f, a: PType): TTypeRelation =
       if sonsLen(f) == 0: 
         # no constraints
         var concrete = concreteType(mapping, a)
-        if concrete != nil: 
-          #MessageOut('putting: ' + f.sym.name.s);
+        if concrete != nil:
           idTablePut(mapping, f, concrete)
           result = isGeneric
       else: