Elsa
Elsa copied to clipboard
Add check for unused variables.
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.