summary refs log tree commit diff stats
diff options
context:
space:
mode:
authordom96 <dominikpicheta@googlemail.com>2011-01-03 23:19:15 +0000
committerdom96 <dominikpicheta@googlemail.com>2011-01-03 23:19:15 +0000
commitbab74b6dce13f69b7f3017b27a472ba4a260c4bb (patch)
treebfd69faedb1a6690415dd77585ac216ac3d8606e
parent958b1cb9769ec3176e40a8cd4ef33b2060b7074d (diff)
downloadNim-bab74b6dce13f69b7f3017b27a472ba4a260c4bb.tar.gz
Fixed a bug in typeToString with generics.
-rwxr-xr-xrod/types.nim14
1 files changed, 6 insertions, 8 deletions
diff --git a/rod/types.nim b/rod/types.nim
index ed9d5271a..32f9c7a94 100755
--- a/rod/types.nim
+++ b/rod/types.nim
@@ -430,8 +430,12 @@ proc TypeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
   if (prefer == preferName) and (t.sym != nil): 
     return t.sym.Name.s
   case t.Kind
-  of tyGenericInst: 
-    result = typeToString(lastSon(t), prefer)
+  of tyGenericBody, tyGenericInst, tyGenericInvokation:
+    result = typeToString(t.sons[0]) & '['
+    for i in countup(1, sonsLen(t) -1 -ord(t.kind != tyGenericInvokation)):
+      if i > 1: add(result, ", ")
+      add(result, typeToString(t.sons[i]))
+    add(result, ']')
   of tyArray: 
     if t.sons[0].kind == tyRange: 
       result = "array[" & rangeToStr(t.sons[0].n) & ", " &
@@ -439,12 +443,6 @@ proc TypeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
     else: 
       result = "array[" & typeToString(t.sons[0]) & ", " &
           typeToString(t.sons[1]) & ']'
-  of tyGenericInvokation, tyGenericBody: 
-    result = typeToString(t.sons[0]) & '['
-    for i in countup(1, sonsLen(t) - 1): 
-      if i > 1: add(result, ", ")
-      add(result, typeToString(t.sons[i]))
-    add(result, ']')
   of tyArrayConstr: 
     result = "Array constructor[" & rangeToStr(t.sons[0].n) & ", " &
         typeToString(t.sons[1]) & ']'