fix #696 - Unused variable fake positive with UFCS

Apparently it was a bug not only specific to the UFCS.
Now every use of the member access operator is handled.
This commit is contained in:
Basile Burg 2018-09-16 16:58:39 +02:00
parent 164ab74338
commit aebb5b4a4c
1 changed files with 9 additions and 4 deletions

View File

@ -199,11 +199,10 @@ final class UnusedVariableCheck : BaseAnalyzer
override void visit(const UnaryExpression unary) override void visit(const UnaryExpression unary)
{ {
if (unary.prefix == tok!"*") const bool interesting = unary.prefix == tok!"*" || unary.unaryExpression !is null;
interestDepth++; interestDepth += interesting;
unary.accept(this); unary.accept(this);
if (unary.prefix == tok!"*") interestDepth -= interesting;
interestDepth--;
} }
override void visit(const MixinExpression mix) override void visit(const MixinExpression mix)
@ -539,6 +538,12 @@ private:
mixin("decl++;"); mixin("decl++;");
} }
void main()
{
const int testValue;
testValue.writeln;
}
}c, sac); }c, sac);
stderr.writeln("Unittest for UnusedVariableCheck passed."); stderr.writeln("Unittest for UnusedVariableCheck passed.");
} }