Fixed a bug in typeToString with generics.

This commit is contained in:
dom96 2011-01-03 23:19:15 +00:00
commit bab74b6dce

View file

@ -430,8 +430,12 @@ proc TypeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
if (prefer == preferName) and (t.sym != nil): if (prefer == preferName) and (t.sym != nil):
return t.sym.Name.s return t.sym.Name.s
case t.Kind case t.Kind
of tyGenericInst: of tyGenericBody, tyGenericInst, tyGenericInvokation:
result = typeToString(lastSon(t), prefer) 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: of tyArray:
if t.sons[0].kind == tyRange: if t.sons[0].kind == tyRange:
result = "array[" & rangeToStr(t.sons[0].n) & ", " & result = "array[" & rangeToStr(t.sons[0].n) & ", " &
@ -439,12 +443,6 @@ proc TypeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
else: else:
result = "array[" & typeToString(t.sons[0]) & ", " & result = "array[" & typeToString(t.sons[0]) & ", " &
typeToString(t.sons[1]) & ']' 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: of tyArrayConstr:
result = "Array constructor[" & rangeToStr(t.sons[0].n) & ", " & result = "Array constructor[" & rangeToStr(t.sons[0].n) & ", " &
typeToString(t.sons[1]) & ']' typeToString(t.sons[1]) & ']'