more informative error msg for undeclared field (A(badfield: 1) and a.badfield = expr) (#17777)

This commit is contained in:
Timothee Cour 2021-05-16 10:03:22 -07:00 • committed by GitHub
commit 3619a5a2aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 3 deletions

View file

@ -429,7 +429,8 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
hasError = true
break
# 2) No such field exists in the constructed type
localError(c.config, field.info, errUndeclaredFieldX % id.s)
let msg = errUndeclaredField % id.s & " for type " & getProcHeader(c.config, t.sym)
localError(c.config, field.info, msg)
hasError = true
break