fix #762 - False positive on "unused variable" with side effect (#763)

This commit is contained in:
Basile-z 2019-05-29 11:11:03 +02:00 committed by GitHub
parent e5a73fa0ef
commit 378cbcc6bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 8 deletions

View File

@ -165,16 +165,11 @@ final class UnusedVariableCheck : BaseAnalyzer
} }
override void visit(const AssignExpression assignExp) override void visit(const AssignExpression assignExp)
{
if (assignExp.ternaryExpression !is null)
assignExp.ternaryExpression.accept(this);
if (assignExp.expression !is null)
{ {
interestDepth++; interestDepth++;
assignExp.expression.accept(this); assignExp.accept(this);
interestDepth--; interestDepth--;
} }
}
override void visit(const TemplateDeclaration templateDeclaration) override void visit(const TemplateDeclaration templateDeclaration)
{ {
@ -543,6 +538,13 @@ private:
cb2(3); cb2(3);
} }
void oops ()
{
class Identity { int val; }
Identity v;
v.val = 0;
}
bool hasDittos(int decl) bool hasDittos(int decl)
{ {
mixin("decl++;"); mixin("decl++;");