Skip to content

Commit 92e5573

Browse files
authored
fix stylecheck error with asyncdispatch (#19350)
* 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
1 parent 955040f commit 92e5573

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

compiler/semtempl.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ proc semTemplSymbol(c: PContext, n: PNode, s: PSym; isField: bool): PNode =
270270
# Issue #12832
271271
when defined(nimsuggest):
272272
suggestSym(c.graph, n.info, s, c.graph.usageSym, false)
273-
if {optStyleHint, optStyleError} * c.config.globalOptions != {}:
273+
# field access (dot expr) will be handled by builtinFieldAccess
274+
if not isField and {optStyleHint, optStyleError} * c.config.globalOptions != {}:
274275
styleCheckUse(c.config, n.info, s)
275276

276277
proc semRoutineInTemplName(c: var TemplCtx, n: PNode): PNode =

tests/stylecheck/taccept.nim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
discard """
2+
matrix: "--styleCheck:error --styleCheck:usages"
3+
"""
4+
5+
import asyncdispatch
6+
7+
type
8+
Name = object
9+
id: int
10+
11+
template hello =
12+
var iD = "string"
13+
var name: Name
14+
doAssert name.id == 0
15+
doAssert iD == "string"
16+
17+
hello()

tests/stylecheck/treject.nim

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
discard """
2+
action: reject
3+
nimout: '''treject.nim(14, 13) Error: 'iD' should be: 'id' [field declared in treject.nim(9, 5)]'''
4+
matrix: "--styleCheck:error --styleCheck:usages"
5+
"""
6+
7+
type
8+
Name = object
9+
id: int
10+
11+
template hello =
12+
var iD = "string"
13+
var name: Name
14+
echo name.iD
15+
echo iD
16+
17+
hello()

0 commit comments

Comments
 (0)