Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix stylecheck error with asyncdispatch #19350

Merged
merged 7 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/semtempl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ proc semTemplSymbol(c: PContext, n: PNode, s: PSym; isField: bool): PNode =
# Issue #12832
when defined(nimsuggest):
suggestSym(c.graph, n.info, s, c.graph.usageSym, false)
if {optStyleHint, optStyleError} * c.config.globalOptions != {}:
# field access (dot expr) will be handled by builtinFieldAccess
if not isField and {optStyleHint, optStyleError} * c.config.globalOptions != {}:
styleCheckUse(c.config, n.info, s)

proc semRoutineInTemplName(c: var TemplCtx, n: PNode): PNode =
Expand Down
17 changes: 17 additions & 0 deletions tests/stylecheck/taccept.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
discard """
matrix: "--styleCheck:error --styleCheck:usages"
"""

import asyncdispatch

type
Name = object
id: int

template hello =
var iD = "string"
var name: Name
doAssert name.id == 0
doAssert iD == "string"

hello()
17 changes: 17 additions & 0 deletions tests/stylecheck/treject.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
discard """
action: reject
nimout: '''treject.nim(14, 13) Error: 'iD' should be: 'id' [field declared in treject.nim(9, 5)]'''
matrix: "--styleCheck:error --styleCheck:usages"
"""

type
Name = object
id: int

template hello =
var iD = "string"
var name: Name
echo name.iD
echo iD

hello()