summary refs log tree commit diff stats
path: root/compiler/semexprs.nim
diff options
context:
space:
mode:
authorIvan Yonchovski <yyoncho@users.noreply.github.com>2022-04-29 12:16:07 +0300
committerGitHub <noreply@github.com>2022-04-29 11:16:07 +0200
commite4a2c2d474f725b01acfa3a6169686f5e16f2ce9 (patch)
treeb3afc59301ba5da1052ed8093543be581b5517fe /compiler/semexprs.nim
parent8bfc396a4dfa722239818f399a119452a53fe07f (diff)
downloadNim-e4a2c2d474f725b01acfa3a6169686f5e16f2ce9.tar.gz
Make sure that field usage preserves the original line info (#19751)
Currently `struct.field` will generate a node with `info` that points to the
symbol definition instead of having the actual node location.
Diffstat (limited to 'compiler/semexprs.nim')
-rw-r--r--compiler/semexprs.nim2
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 702b47929..b8742ff65 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -1436,8 +1436,10 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
         # is the access to a public field or in the same module or in a friend?
         markUsed(c, n[1].info, f)
         onUse(n[1].info, f)
+        let info = n[1].info
         n[0] = makeDeref(n[0])
         n[1] = newSymNode(f) # we now have the correct field
+        n[1].info = info # preserve the original info
         n.typ = f.typ
         if check == nil:
           result = n