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.
This commit is contained in:
parent
e0d13abaff
commit
5b3571c9a4
2 changed files with 17 additions and 2 deletions
|
|
@ -729,7 +729,11 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
|
||||||
else: rectype.sym
|
else: rectype.sym
|
||||||
for i in 0 .. len(n)-3:
|
for i in 0 .. len(n)-3:
|
||||||
var f = semIdentWithPragma(c, skField, n.sons[i], {sfExported})
|
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.typ = typ
|
||||||
f.position = pos
|
f.position = pos
|
||||||
f.options = c.config.options
|
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)
|
f.flags = f.flags + ({sfImportc, sfExportc} * fieldOwner.flags)
|
||||||
inc(pos)
|
inc(pos)
|
||||||
if containsOrIncl(check, f.name.id):
|
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))
|
if a.kind == nkEmpty: addSon(father, newSymNode(f))
|
||||||
else: addSon(a, newSymNode(f))
|
else: addSon(a, newSymNode(f))
|
||||||
styleCheckDef(c.config, f)
|
styleCheckDef(c.config, f)
|
||||||
|
|
|
||||||
11
nimsuggest/tests/tobj_highlight.nim
Normal file
11
nimsuggest/tests/tobj_highlight.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
type
|
||||||
|
O = object
|
||||||
|
a*: int#[!]#
|
||||||
|
|
||||||
|
discard """
|
||||||
|
$nimsuggest --tester $file
|
||||||
|
>highlight $1
|
||||||
|
highlight;;skType;;2;;2;;1
|
||||||
|
highlight;;skType;;3;;8;;3
|
||||||
|
highlight;;skField;;3;;4;;1
|
||||||
|
"""
|
||||||
Loading…
Add table
Add a link
Reference in a new issue