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
⚡ Feature: Variable usage checker #32
Merged
deavmi
merged 19 commits into
vardec_varass_dependency
from
feature/unused_vars_detection
Apr 1, 2024
Merged
⚡ Feature: Variable usage checker #32
deavmi
merged 19 commits into
vardec_varass_dependency
from
feature/unused_vars_detection
Apr 1, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Added `varRefCounts` which maps a given `Variable` to its reference count. This includes the declaration thereof. - Added `touch(Variable variable)` which Increments the given variable's reference count
- When handling a standalone assignment to a variable increment it's reference count - This was updated in the handling of `VariableAssignmentStdAlone`
- Make variable declaration count as the first reference
- VAriables that appear in expressions must increase the ref count
- Added `getUnusedVariables()` which returns all variables which were declared but not used
- Moved the reference counting mechanism into the `TypeChecker` to avoid problem of seperate `DNodeGenerator` instances having their own seperate counts - We now check the reference count values after function definition processing so as to get a proper count Dependency - Use the reference counting from `TypeChecker` - Removed reference counting code Test cases - Added a positive case in the form of `unused_vars.t` - Added a negative case in the form of `unused_vars_none.t`
- We now respect the `typecheck:warnUnusedVars` option
- Added `doPostChecks()` - Moved the reference counting code to `doPostChecks()`
deavmi
changed the title
🧠 Ideation: Variable usage checker
⚡ Feature: Variable usage checker
Nov 4, 2023
- `defaultConfig()` now adds an entry for `typecheck:warnUnusedVars` set to `true`
- Use `getName()` on the `Variable` when printing out the names of unused variables
- Added a positive test case unittest for the unused variables detection mechanism
- Check the variable is equal to the one we are looking for (`j`)
- Added a negative test case for the unused variables detection mechanism
- Fixed message which prints out when an unused variable is detected
Merging... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please see this for more information.