misc cleanups in compiler msgs: use toHumanStr, etc (#14677)

This commit is contained in:
Timothee Cour 2020-06-15 21:17:24 -07:00 • committed by GitHub
commit faedb14a16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 12 deletions

View file

@ -905,8 +905,7 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
if t.kind == tyTypeDesc and tfUnresolved notin t.flags:
t = t.base
if t.kind == tyVoid:
const kindToStr: array[tyPtr..tyRef, string] = ["ptr", "ref"]
localError(c.config, n.info, "type '$1 void' is not allowed" % kindToStr[kind])
localError(c.config, n.info, "type '$1 void' is not allowed" % kind.toHumanStr)
result = newOrPrevType(kind, prev, c)
var isNilable = false
var wrapperKind = tyNone
@ -1400,7 +1399,7 @@ proc semObjectTypeForInheritedGenericInst(c: PContext, n: PNode, t: PType) =
proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType =
if s.typ == nil:
localError(c.config, n.info, "cannot instantiate the '$1' $2" %
[s.name.s, ($s.kind).substr(2).toLowerAscii])
[s.name.s, s.kind.toHumanStr])
return newOrPrevType(tyError, prev, c)
var t = s.typ