This commit is contained in:
parent
0f91b67f5c
commit
f258e4e70c
2 changed files with 19 additions and 15 deletions
|
|
@ -8,11 +8,10 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
# This module implements lookup helpers.
|
# This module implements lookup helpers.
|
||||||
|
import std/[algorithm, strutils]
|
||||||
import
|
import
|
||||||
intsets, ast, astalgo, idents, semdata, types, msgs, options,
|
intsets, ast, astalgo, idents, semdata, types, msgs, options,
|
||||||
renderer, nimfix/prettybase, lineinfos, strutils,
|
renderer, nimfix/prettybase, lineinfos, modulegraphs, astmsgs
|
||||||
modulegraphs, astmsgs
|
|
||||||
|
|
||||||
proc ensureNoMissingOrUnusedSymbols(c: PContext; scope: PScope)
|
proc ensureNoMissingOrUnusedSymbols(c: PContext; scope: PScope)
|
||||||
|
|
||||||
|
|
@ -268,6 +267,7 @@ proc ensureNoMissingOrUnusedSymbols(c: PContext; scope: PScope) =
|
||||||
var it: TTabIter
|
var it: TTabIter
|
||||||
var s = initTabIter(it, scope.symbols)
|
var s = initTabIter(it, scope.symbols)
|
||||||
var missingImpls = 0
|
var missingImpls = 0
|
||||||
|
var unusedSyms: seq[tuple[sym: PSym, key: string]]
|
||||||
while s != nil:
|
while s != nil:
|
||||||
if sfForward in s.flags and s.kind notin {skType, skModule}:
|
if sfForward in s.flags and s.kind notin {skType, skModule}:
|
||||||
# too many 'implementation of X' errors are annoying
|
# too many 'implementation of X' errors are annoying
|
||||||
|
|
@ -282,8 +282,10 @@ proc ensureNoMissingOrUnusedSymbols(c: PContext; scope: PScope) =
|
||||||
# maybe they can be made skGenericParam as well.
|
# maybe they can be made skGenericParam as well.
|
||||||
if s.typ != nil and tfImplicitTypeParam notin s.typ.flags and
|
if s.typ != nil and tfImplicitTypeParam notin s.typ.flags and
|
||||||
s.typ.kind != tyGenericParam:
|
s.typ.kind != tyGenericParam:
|
||||||
message(c.config, s.info, hintXDeclaredButNotUsed, s.name.s)
|
unusedSyms.add (s, toFileLineCol(c.config, s.info))
|
||||||
s = nextIter(it, scope.symbols)
|
s = nextIter(it, scope.symbols)
|
||||||
|
for (s, _) in sortedByIt(unusedSyms, it.key):
|
||||||
|
message(c.config, s.info, hintXDeclaredButNotUsed, s.name.s)
|
||||||
|
|
||||||
proc wrongRedefinition*(c: PContext; info: TLineInfo, s: string;
|
proc wrongRedefinition*(c: PContext; info: TLineInfo, s: string;
|
||||||
conflictsWith: TLineInfo) =
|
conflictsWith: TLineInfo) =
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
discard """
|
discard """
|
||||||
|
matrix: "--hint:all:off --hint:XDeclaredButNotUsed"
|
||||||
|
nimoutFull: true
|
||||||
nimout: '''
|
nimout: '''
|
||||||
treportunused.nim(19, 10) Hint: 's1' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(21, 10) Hint: 's1' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(26, 5) Hint: 's8' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(22, 10) Hint: 's2' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(22, 6) Hint: 's4' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(23, 10) Hint: 's3' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(25, 7) Hint: 's7' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(24, 6) Hint: 's4' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(24, 7) Hint: 's6' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(25, 6) Hint: 's5' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(23, 6) Hint: 's5' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(26, 7) Hint: 's6' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(20, 10) Hint: 's2' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(27, 7) Hint: 's7' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(29, 6) Hint: 's11' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(28, 5) Hint: 's8' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(27, 5) Hint: 's9' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(29, 5) Hint: 's9' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(21, 10) Hint: 's3' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(30, 6) Hint: 's10' is declared but not used [XDeclaredButNotUsed]
|
||||||
treportunused.nim(28, 6) Hint: 's10' is declared but not used [XDeclaredButNotUsed]
|
treportunused.nim(31, 6) Hint: 's11' is declared but not used [XDeclaredButNotUsed]
|
||||||
'''
|
'''
|
||||||
action: compile
|
action: compile
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue