summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-07-19 08:41:57 +0200
committerAraq <rumpf_a@web.de>2012-07-19 08:41:57 +0200
commitc9513c2e5a42e6a34e11568a708d3db80d2b6283 (patch)
treeb0afda9b00088e3e9d7c96acf915572f546cfb60 /compiler
parentb9e7f30dda8a066e7a5e439b98d94fc729c1d9b5 (diff)
downloadNim-c9513c2e5a42e6a34e11568a708d3db80d2b6283.tar.gz
bugfix: constraint matching for tyGenericInst; implements #130
Diffstat (limited to 'compiler')
-rwxr-xr-xcompiler/semtypes.nim9
-rwxr-xr-xcompiler/sigmatch.nim2
2 files changed, 9 insertions, 2 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index e9cb8babb..3aafd2492 100755
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -198,7 +198,14 @@ proc semTypeIdent(c: PContext, n: PNode): PSym =
             return result.typ.sym
         else:
           return result.typ.sym
-      if result.kind != skType: GlobalError(n.info, errTypeExpected)
+      if result.kind != skType: 
+        # this implements the wanted ``var v: V, x: V`` feature ...
+        var ov: TOverloadIter
+        var amb = InitOverloadIter(ov, c, n)
+        while amb != nil and amb.kind != skType:
+          amb = nextOverloadIter(ov, c, n)
+        if amb != nil: result = amb
+        else: GlobalError(n.info, errTypeExpected)
       if result.typ.kind != tyGenericParam:
         # XXX get rid of this hack!
         reset(n[])
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index af924bafe..6021d27ab 100755
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -249,7 +249,7 @@ proc tupleRel(c: var TCandidate, f, a: PType): TTypeRelation =
 proc matchTypeClass(c: var TCandidate, f, a: PType): TTypeRelation =
   for i in countup(0, f.sonsLen - 1):
     let son = f.sons[i]
-    var match = son.kind == skipTypes(a, {tyRange}).kind
+    var match = son.kind == skipTypes(a, {tyRange, tyGenericInst}).kind
 
     if not match:
       case son.kind