summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authoralaviss <alaviss@users.noreply.github.com>2019-01-21 22:57:48 +0700
committerAndreas Rumpf <rumpf_a@web.de>2019-01-21 16:57:48 +0100
commit413755fd45f5a77f9c3323cf7185830249c3f310 (patch)
tree9b9ef348433727ffe9675748c201bb91e87cc9bf /compiler/semstmts.nim
parent4bea8dd674c87b49195220bd6c5d72def467d8e5 (diff)
downloadNim-413755fd45f5a77f9c3323cf7185830249c3f310.tar.gz
Correct lineinfo for accent quoted symbols in proc definition (#10399)
* compiler/parser: preserve lineinfo for accent quoted symbols

Previously the lineinfo for symbol $$$ in this example is:

    proc `$$$`
             ^

After this commit:

    proc `$$$`
          ^

* compiler/semstmts: correct lineinfo for accent quoted idents

Previously nimsuggest would highlight this as:

    proc `$$$`
         ^~~

After this commit:

    proc `$$$`
          ^~~

* nimsuggest/tests: add a test for accent quoted proc

Disabled by default
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim20
1 files changed, 10 insertions, 10 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index de39e95c8..288820d86 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -318,16 +318,16 @@ proc semIdentDef(c: PContext, n: PNode, kind: TSymKind): PSym =
     result = semIdentWithPragma(c, kind, n, {})
     if result.owner.kind == skModule:
       incl(result.flags, sfGlobal)
-  let info = case n.kind
-             of nkPostfix:
-               n.sons[1].info
-             of nkPragmaExpr:
-               if n.sons[0].kind == nkPostfix:
-                 n.sons[0].sons[1].info
-               else:
-                 n.sons[0].info
-             else:
-               n.info
+
+  proc getLineInfo(n: PNode): TLineInfo =
+    case n.kind
+    of nkPostfix:
+      getLineInfo(n.sons[1])
+    of nkAccQuoted, nkPragmaExpr:
+      getLineInfo(n.sons[0])
+    else:
+      n.info
+  let info = getLineInfo(n)
   suggestSym(c.config, info, result, c.graph.usageSym)
 
 proc checkNilable(c: PContext; v: PSym) =