Skip to content

Commit

Permalink
Dependency
Browse files Browse the repository at this point in the history
- Added `getUnusedVariables()` which returns all variables which were declared but not used
  • Loading branch information
deavmi committed Nov 3, 2023
1 parent 36c29f1 commit 94555a3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions source/tlang/compiler/typecheck/dependency/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -1736,4 +1736,24 @@ public class DNodeGenerator
this.varRefCounts[variable]++;
}

/**
* Returns all variables which were declared
* but not used
*
* Returns: the array of variables
*/
public Variable[] getUnusedVariables()
{
Variable[] unused;
foreach(Variable variable; this.varRefCounts.keys())
{
if(!(this.varRefCounts[variable] > 1))
{
unused ~= variable;
}
}

return unused;
}

}

0 comments on commit 94555a3

Please sign in to comment.