Skip to content

Commit

Permalink
fix #762 - False positive on "unused variable" with side effect (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
Basile-z authored May 29, 2019
1 parent e5a73fa commit 378cbcc
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/dscanner/analysis/unused.d
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,9 @@ final class UnusedVariableCheck : BaseAnalyzer

override void visit(const AssignExpression assignExp)
{
if (assignExp.ternaryExpression !is null)
assignExp.ternaryExpression.accept(this);
if (assignExp.expression !is null)
{
interestDepth++;
assignExp.expression.accept(this);
interestDepth--;
}
interestDepth++;
assignExp.accept(this);
interestDepth--;
}

override void visit(const TemplateDeclaration templateDeclaration)
Expand Down Expand Up @@ -542,6 +537,13 @@ private:
auto cb2 = delegate(size_t a) {}; // [warn]: Parameter a is never used.
cb2(3);
}

void oops ()
{
class Identity { int val; }
Identity v;
v.val = 0;
}

bool hasDittos(int decl)
{
Expand Down

0 comments on commit 378cbcc

Please sign in to comment.