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,12 +234,17 @@ class UnusedVariableCheck : BaseAnalyzer
|
||||||
{
|
{
|
||||||
foreach (part; matchAll(primary.primary.text, re))
|
foreach (part; matchAll(primary.primary.text, re))
|
||||||
{
|
{
|
||||||
immutable size_t treeIndex = tree.length - 1;
|
void checkTree(in size_t treeIndex)
|
||||||
|
{
|
||||||
auto uu = UnUsed(part.hit);
|
auto uu = UnUsed(part.hit);
|
||||||
auto r = tree[treeIndex].equalRange(&uu);
|
auto r = tree[treeIndex].equalRange(&uu);
|
||||||
if (!r.empty)
|
if (!r.empty)
|
||||||
r.front.uncertain = true;
|
r.front.uncertain = true;
|
||||||
}
|
}
|
||||||
|
checkTree(tree.length - 1);
|
||||||
|
if (tree.length >= 2)
|
||||||
|
checkTree(tree.length - 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
primary.accept(this);
|
primary.accept(this);
|
||||||
|
@ -407,6 +412,8 @@ private:
|
||||||
{
|
{
|
||||||
if (!uu.isRef && tree.length > 1)
|
if (!uu.isRef && tree.length > 1)
|
||||||
{
|
{
|
||||||
|
if (uu.uncertain)
|
||||||
|
continue;
|
||||||
immutable string certainty = uu.uncertain ? " might not be used."
|
immutable string certainty = uu.uncertain ? " might not be used."
|
||||||
: " is never used.";
|
: " is never used.";
|
||||||
immutable string errorMessage = (uu.isParameter ? "Parameter " : "Variable ")
|
immutable string errorMessage = (uu.isParameter ? "Parameter " : "Variable ")
|
||||||
|
@ -527,6 +534,11 @@ private:
|
||||||
cb2(3);
|
cb2(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasDittos(int decl)
|
||||||
|
{
|
||||||
|
mixin("decl++;");
|
||||||
|
}
|
||||||
|
|
||||||
}c, sac);
|
}c, sac);
|
||||||
stderr.writeln("Unittest for UnusedVariableCheck passed.");
|
stderr.writeln("Unittest for UnusedVariableCheck passed.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue