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
This commit is contained in:
flywind 2022-04-08 14:04:46 +08:00 • committed by GitHub
commit 00775f6880
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -1188,6 +1188,7 @@ proc semSym(c: PContext, n: PNode, sym: PSym, flags: TExprFlags): PNode =
let s = getGenSym(c, sym) let s = getGenSym(c, sym)
case s.kind case s.kind
of skConst: of skConst:
if n.kind != nkDotExpr: # dotExpr is already checked by builtinFieldAccess
markUsed(c, n.info, s) markUsed(c, n.info, s)
onUse(n.info, s) onUse(n.info, s)
let typ = skipTypes(s.typ, abstractInst-{tyTypeDesc}) let typ = skipTypes(s.typ, abstractInst-{tyTypeDesc})
@ -1249,6 +1250,7 @@ proc semSym(c: PContext, n: PNode, sym: PSym, flags: TExprFlags): PNode =
if s.magic == mNimvm: if s.magic == mNimvm:
localError(c.config, n.info, "illegal context for 'nimvm' magic") localError(c.config, n.info, "illegal context for 'nimvm' magic")
if n.kind != nkDotExpr: # dotExpr is already checked by builtinFieldAccess
markUsed(c, n.info, s) markUsed(c, n.info, s)
onUse(n.info, s) onUse(n.info, s)
result = newSymNode(s, n.info) result = newSymNode(s, n.info)
@ -1270,6 +1272,7 @@ proc semSym(c: PContext, n: PNode, sym: PSym, flags: TExprFlags): PNode =
n.typ = s.typ n.typ = s.typ
return n return n
of skType: of skType:
if n.kind != nkDotExpr: # dotExpr is already checked by builtinFieldAccess
markUsed(c, n.info, s) markUsed(c, n.info, s)
onUse(n.info, s) onUse(n.info, s)
if s.typ.kind == tyStatic and s.typ.base.kind != tyNone and s.typ.n != nil: if s.typ.kind == tyStatic and s.typ.base.kind != tyNone and s.typ.n != nil:

View file

@ -2,7 +2,7 @@ discard """
matrix: "--styleCheck:error --styleCheck:usages" matrix: "--styleCheck:error --styleCheck:usages"
""" """
import asyncdispatch import std/[asyncdispatch, nre]
type type
Name = object Name = object