summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2014-02-18 01:37:00 +0200
committerZahary Karadjov <zahary@gmail.com>2014-02-18 01:37:00 +0200
commit4d3846e26b38ddf7fade05489f0f3335db057950 (patch)
tree2ad015b71f5e78f750bb6ba57706986a62de8837 /compiler
parent765c682c92f27e13d079b146941033d7b68e261b (diff)
downloadNim-4d3846e26b38ddf7fade05489f0f3335db057950.tar.gz
fix tbindtypedesc and tactiontable2
Diffstat (limited to 'compiler')
-rw-r--r--compiler/sigmatch.nim17
1 files changed, 12 insertions, 5 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 5fe474ef3..240145118 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -900,20 +900,27 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
       result = isNone
 
   of tyTypeDesc:
-    if a.kind != tyTypeDesc: return isNone
-    
     var prev = PType(idTableGet(c.bindings, f))
     if prev == nil:
+      # proc foo(T: typedesc, x: T)
+      # when `f` is an unresolved typedesc, `a` could be any
+      # type, so we should not perform this check earlier
+      if a.kind != tyTypeDesc: return isNone
+    
       if f.base.kind == tyNone:
         result = isGeneric
       else:
         result = typeRel(c, f.base, a.base)
+      
       if result != isNone:
         put(c.bindings, f, a)
     else:
-      let toMatch = if tfUnresolved in f.flags: a
-                    else: a.base
-      result = typeRel(c, prev.base, toMatch)
+      if tfUnresolved in f.flags:
+        result = typeRel(c, prev.base, a)
+      elif a.kind == tyTypeDesc:
+        result = typeRel(c, prev.base, a.base)
+      else:
+        result = isNone
   
   of tyStmt:
     result = isGeneric