-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
warning for unused symbols and stdout/stderr output validation #147
Conversation
- adapted test case
- moved the usage check to class Scope
- added output verification to test case
- added output verification to test case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Easy but important change required.
.foreach(d => { | ||
println(s"${YELLOW}${BOLD}symbol '${d.name}' defined in ${d.pos.filename} line: ${d.pos.pos.line} but never used${RESET}") | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to make a recursive check for includedScopes
as well. Test-case:
{
def y = 10
}
Note the braces which introduces a new scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct me if I'm wrong, but I think the method definitions in class Scope retrieves the parent and recursively the definitions from the included scopes in private def allLocalDefinitions:
private val localDefinitions = Helper.filterByType[Definition](entries)
private def allLocalDefinitions: Seq[Definition] = localDefinitions ++ includedScopes.flatMap(_.allLocalDefinitions)
def definitions:Seq[Definition] = {
val parentDefinitions = parentOpt.map(_.definitions).getOrElse(Nil)
val allLocalDefs = allLocalDefinitions
val allLocalNames = allLocalDefs.map(_.name)
parentDefinitions.filter(d => !allLocalNames.contains(d.name)) ++ allLocalDefs
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. you seem to be right. The test case fails though (no warning).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's curious... I'll check it tonight
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, the problem is that those nested scopes we're looking for are not within the includedScopes, but childScopes. The method checkUnusedSymbols() must be called on the childScopes, too. I'm going to push my change in a moment.
Additional PR for #104 for stdout/stderr output validation