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

@ -490,7 +490,12 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
result.kind = tyUserTypeClassInst
of tyGenericBody:
localError(cl.c.config, cl.info, "cannot instantiate: '" & typeToString(t) & "'")
localError(
cl.c.config,
cl.info,
"cannot instantiate: '" &
typeToString(t, preferDesc) &
"'; Maybe generic arguments are missing?")
result = errorType(cl.c)
#result = replaceTypeVarsT(cl, lastSon(t))
@ -555,6 +560,14 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType =
for i in countup(0, sonsLen(result) - 1):
if result.sons[i] != nil:
if result.sons[i].kind == tyGenericBody:
localError(
cl.c.config,
t.sym.info,
"cannot instantiate '" &
typeToString(result.sons[i], preferDesc) &
"' inside of type definition: '" &
t.owner.name.s & "'; Maybe generic arguments are missing?")
var r = replaceTypeVarsT(cl, result.sons[i])
if result.kind == tyObject:
# carefully coded to not skip the precious tyGenericInst: