Fix for issue #10342. better message for generic subclass instantiation (#10354)

* Fix for issue #10342. better message for generic subclass instantiation errors.
This commit is contained in:
Ray Imber 2019-01-22 17:05:26 -08:00 • committed by Timothee Cour
commit 94f6a6b294
4 changed files with 33 additions and 4 deletions

View file

@ -456,12 +456,18 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
result = $t.n.intVal
else:
result = "int literal(" & $t.n.intVal & ")"
of tyGenericBody, tyGenericInst, tyGenericInvocation:
of tyGenericInst, tyGenericInvocation:
result = typeToString(t.sons[0]) & '['
for i in countup(1, sonsLen(t)-1-ord(t.kind != tyGenericInvocation)):
if i > 1: add(result, ", ")
add(result, typeToString(t.sons[i], preferGenericArg))
add(result, ']')
of tyGenericBody:
result = typeToString(t.lastSon) & '['
for i in countup(0, sonsLen(t)-2):
if i > 0: add(result, ", ")
add(result, typeToString(t.sons[i], preferTypeName))
add(result, ']')
of tyTypeDesc:
if t.sons[0].kind == tyNone: result = "typedesc"
else: result = "type " & typeToString(t.sons[0])
@ -612,7 +618,6 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
result = typeToStr[t.kind]
result.addTypeFlags(t)
proc firstOrd*(conf: ConfigRef; t: PType): BiggestInt =
case t.kind
of tyBool, tyChar, tySequence, tyOpenArray, tyString, tyVarargs, tyProxy: