summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authoralaviss <alaviss@users.noreply.github.com>2019-10-24 23:06:53 +0000
committerAndreas Rumpf <rumpf_a@web.de>2019-10-25 01:06:53 +0200
commit5b3571c9a4b468ee95eae5d05d37d54f3016d9cd (patch)
treea99e30fe627a292ae381ef68036d3c5c4df88df0 /compiler
parente0d13abaff1192ae6b1f4ae5cd89ae742627b680 (diff)
downloadNim-5b3571c9a4b468ee95eae5d05d37d54f3016d9cd.tar.gz
compiler/semtypes: improve lineinfo for exported object fields (#12495)
The line info should now points to the `a`, not the `*`, like this:
    a*: string
    ^
Additionally this fixes nimsuggest's highlighting of exported object
fields.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semtypes.nim8
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim
index 3fdeb144d..fd5ee0598 100644
--- a/compiler/semtypes.nim
+++ b/compiler/semtypes.nim
@@ -729,7 +729,11 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
                      else: rectype.sym
     for i in 0 .. len(n)-3:
       var f = semIdentWithPragma(c, skField, n.sons[i], {sfExported})
-      suggestSym(c.config, n.sons[i].info, f, c.graph.usageSym)
+      let info = if n.sons[i].kind == nkPostfix:
+                   n.sons[i].sons[1].info
+                 else:
+                   n.sons[i].info
+      suggestSym(c.config, info, f, c.graph.usageSym)
       f.typ = typ
       f.position = pos
       f.options = c.config.options
@@ -740,7 +744,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
         f.flags = f.flags + ({sfImportc, sfExportc} * fieldOwner.flags)
       inc(pos)
       if containsOrIncl(check, f.name.id):
-        localError(c.config, n.sons[i].info, "attempt to redefine: '" & f.name.s & "'")
+        localError(c.config, info, "attempt to redefine: '" & f.name.s & "'")
       if a.kind == nkEmpty: addSon(father, newSymNode(f))
       else: addSon(a, newSymNode(f))
       styleCheckDef(c.config, f)