summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2012-09-13 03:02:36 +0300
committerZahary Karadjov <zahary@gmail.com>2012-09-13 03:03:12 +0300
commitb2814df5cdfe5a7713d54c366fa798c92793ace8 (patch)
tree4c4f2fc39779319c9ded11e09784ca5e550f2148 /compiler
parent254bc714dd398e5e2bbbd3cc1c82e07a21bbcf4d (diff)
downloadNim-b2814df5cdfe5a7713d54c366fa798c92793ace8.tar.gz
fixed incorrect implicit conversion between arrays of different sizes; see #202
Diffstat (limited to 'compiler')
-rwxr-xr-xcompiler/sigmatch.nim25
1 files changed, 12 insertions, 13 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 1f4c9653e..4d407fcb6 100755
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -370,23 +370,22 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
   of tyVar: 
     if a.kind == f.kind: result = typeRel(c, base(f), base(a))
     else: result = typeRel(c, base(f), a)
-  of tyArray, tyArrayConstr: 
+  of tyArray, tyArrayConstr:
     # tyArrayConstr cannot happen really, but
     # we wanna be safe here
     case a.kind
-    of tyArray: 
-      result = minRel(typeRel(c, f.sons[0], a.sons[0]), 
-                      typeRel(c, f.sons[1], a.sons[1]))
-      if result < isGeneric: result = isNone
-    of tyArrayConstr: 
+    of tyArray, tyArrayConstr:
+      var fRange = f.sons[0]
+      if fRange.kind == tyGenericParam:
+        var prev = PType(idTableGet(c.bindings, fRange))
+        if prev == nil:
+          put(c.bindings, fRange, a.sons[0])
+          fRange = a
+        else:
+          fRange = prev
       result = typeRel(c, f.sons[1], a.sons[1])
-      if result < isGeneric: 
-        result = isNone
-      else: 
-        if (result != isGeneric) and (lengthOrd(f) != lengthOrd(a)): 
-          result = isNone
-        elif f.sons[0].kind in GenericTypes: 
-          result = minRel(result, typeRel(c, f.sons[0], a.sons[0]))
+      if result < isGeneric: result = isNone
+      elif lengthOrd(fRange) != lengthOrd(a): result = isNone
     else: nil
   of tyOpenArray, tyVarargs:
     case a.Kind