Elsa icon indicating copy to clipboard operation
Elsa copied to clipboard

Add check for unused variables.

Open Fuco1 opened this issue 7 years ago • 0 comments

This should probably be tracked on the scope because as we nest bindings variables get pushed and popped and so the information would get mixed.

We can simply walk through the scope and on the first use set a flag. When we are popping a variable, check if it was never used in the scope and flag it as a warning.

Beware, the popping might happen as implementation detail for example in conditionals narrowing... we should only disregard the information when popping a "defining" entry like a binding from let or defun. Otherwise the information needs to be propagated upwards.

To make this simple we should probably add the defining form to the variable class so that we can refer back to it later.

  • [ ] Add form to the variable class
  • [ ] Extend scope with usage tracking information
  • [ ] Add a check for usage.

Fuco1 avatar Aug 10 '18 13:08 Fuco1