followup #17777: declaredloc field error msgs now work with generics (#18259)

* followup #17777: declaredloc field error msgs now work with generics

* fix tests

* cleanup
This commit is contained in:
Timothee Cour 2021-06-13 23:21:18 -07:00 • committed by GitHub
commit 065243dc59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 17 deletions

View file

@ -326,7 +326,7 @@ proc getMsgDiagnostic(c: PContext, flags: TExprFlags, n, f: PNode): string =
let ident = considerQuotedIdent(c, f, n).s
if {nfDotField, nfExplicitCall} * n.flags == {nfDotField}:
let sym = n[1].typ.sym
let sym = n[1].typ.typSym
var typeHint = ""
if sym == nil:
# Perhaps we're in a `compiles(foo.bar)` expression, or
@ -337,7 +337,8 @@ proc getMsgDiagnostic(c: PContext, flags: TExprFlags, n, f: PNode): string =
discard
else:
typeHint = " for type " & getProcHeader(c.config, sym)
result = errUndeclaredField % ident & typeHint & " " & result
let suffix = if result.len > 0: " " & result else: ""
result = errUndeclaredField % ident & typeHint & suffix
else:
if result.len == 0: result = errUndeclaredRoutine % ident
else: result = errBadRoutine % [ident, result]