Check for function parameters in mixins (#484)
* Check for function parameters in mixins * Don't trigger errors on uncertain mesages
This commit is contained in:
parent
2be1a1f22f
commit
27b09eebfd
|
@ -234,11 +234,16 @@ class UnusedVariableCheck : BaseAnalyzer
|
|||
{
|
||||
foreach (part; matchAll(primary.primary.text, re))
|
||||
{
|
||||
immutable size_t treeIndex = tree.length - 1;
|
||||
auto uu = UnUsed(part.hit);
|
||||
auto r = tree[treeIndex].equalRange(&uu);
|
||||
if (!r.empty)
|
||||
r.front.uncertain = true;
|
||||
void checkTree(in size_t treeIndex)
|
||||
{
|
||||
auto uu = UnUsed(part.hit);
|
||||
auto r = tree[treeIndex].equalRange(&uu);
|
||||
if (!r.empty)
|
||||
r.front.uncertain = true;
|
||||
}
|
||||
checkTree(tree.length - 1);
|
||||
if (tree.length >= 2)
|
||||
checkTree(tree.length - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -407,6 +412,8 @@ private:
|
|||
{
|
||||
if (!uu.isRef && tree.length > 1)
|
||||
{
|
||||
if (uu.uncertain)
|
||||
continue;
|
||||
immutable string certainty = uu.uncertain ? " might not be used."
|
||||
: " is never used.";
|
||||
immutable string errorMessage = (uu.isParameter ? "Parameter " : "Variable ")
|
||||
|
@ -526,6 +533,11 @@ private:
|
|||
auto cb2 = delegate(size_t a) {}; // [warn]: Parameter a is never used.
|
||||
cb2(3);
|
||||
}
|
||||
|
||||
bool hasDittos(int decl)
|
||||
{
|
||||
mixin("decl++;");
|
||||
}
|
||||
|
||||
}c, sac);
|
||||
stderr.writeln("Unittest for UnusedVariableCheck passed.");
|
||||
|
|
Loading…
Reference in New Issue