summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2022-04-08 14:04:46 +0800
committerGitHub <noreply@github.com>2022-04-08 08:04:46 +0200
commit00775f6880733695d187d84bb742e8c9d6c65d6d (patch)
treec67a6968e95a65fcdc6344f92a62fcf1989170e2
parente78ef57c93d66da483e0482ce0907dfe16dc8d27 (diff)
downloadNim-00775f6880733695d187d84bb742e8c9d6c65d6d.tar.gz
fix stylecheck bug with nre (#19356)
* stylecheck usages part two: stdlib cleanup

typeinfo.nim: importCompilerProc => importcompilerproc

nre.nim: newLineFlags => newlineFlags

system.nim: JSRoot => JsRoot

ref #19319

* prefer importCompilerProc

* fix stylecheck error with asyncdispatch

it is a partial regression since #12842

* add tests

* don't use echo in tests

* fix stylecheck bug with nre

* Update compiler/linter.nim

* no need to check dotexpr again

* neither did let/var/const
-rw-r--r--compiler/semexprs.nim9
-rw-r--r--tests/stylecheck/taccept.nim2
2 files changed, 7 insertions, 4 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index f224bd0b3..702b47929 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -1188,7 +1188,8 @@ proc semSym(c: PContext, n: PNode, sym: PSym, flags: TExprFlags): PNode =
   let s = getGenSym(c, sym)
   case s.kind
   of skConst:
-    markUsed(c, n.info, s)
+    if n.kind != nkDotExpr: # dotExpr is already checked by builtinFieldAccess
+      markUsed(c, n.info, s)
     onUse(n.info, s)
     let typ = skipTypes(s.typ, abstractInst-{tyTypeDesc})
     case typ.kind
@@ -1249,7 +1250,8 @@ proc semSym(c: PContext, n: PNode, sym: PSym, flags: TExprFlags): PNode =
     if s.magic == mNimvm:
       localError(c.config, n.info, "illegal context for 'nimvm' magic")
 
-    markUsed(c, n.info, s)
+    if n.kind != nkDotExpr: # dotExpr is already checked by builtinFieldAccess
+      markUsed(c, n.info, s)
     onUse(n.info, s)
     result = newSymNode(s, n.info)
     # We cannot check for access to outer vars for example because it's still
@@ -1270,7 +1272,8 @@ proc semSym(c: PContext, n: PNode, sym: PSym, flags: TExprFlags): PNode =
       n.typ = s.typ
       return n
   of skType:
-    markUsed(c, n.info, s)
+    if n.kind != nkDotExpr: # dotExpr is already checked by builtinFieldAccess
+      markUsed(c, n.info, s)
     onUse(n.info, s)
     if s.typ.kind == tyStatic and s.typ.base.kind != tyNone and s.typ.n != nil:
       return s.typ.n
diff --git a/tests/stylecheck/taccept.nim b/tests/stylecheck/taccept.nim
index 6fb55f835..afe02a65c 100644
--- a/tests/stylecheck/taccept.nim
+++ b/tests/stylecheck/taccept.nim
@@ -2,7 +2,7 @@ discard """
   matrix: "--styleCheck:error --styleCheck:usages"
 """
 
-import asyncdispatch
+import std/[asyncdispatch, nre]
 
 type
   Name = object