mirror of https://github.com/tbklang/tlang.git
⚡ Feature: Variable usage checker #159
Labels
No Label
dependency
emit
hashmapper
lebanonmapper
lexer
meta
needsfix
parser
qol
question
resolution
typing
No Milestone
No project
No Assignees
1 Participants
Notifications
Total Time Spent: 3 hours 10 minutes
Due Date
deavmi
3 hours 10 minutes
Blocks
#157 ⚡ Feature: Multi-module support
tlang/tlang
Reference: tlang/tlang#159
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What is this?
We can add a component to the dependency generator which tracks the usage of variables. We can then call something like
touch(Varable)
whenever one is referenced.This can then increment an entry in a hashmap.
For the quickest implementation for then comparing we should
touch(Variable)
on declaration as well and not just reference. Therefore we have them all in the hashmap and can find all0
count ones, (or well,1
count actually). Anything with a count of1
is then unused and we can warn the user about this.Todo
touch(Variable)
touch(Variable)
1
-count variables and then returns them as an array ofstring[]
for their identifiersTests
Documentation
typecheck:warnUnusedVars
### Ideation: Variable usage checkerto 🧠 Ideation: Variable usage checkervardec_varass_dependencyto feature/unused_vars_detectionGot most of it done, the API and the usage of
touch(Variable)
where it needs to be.Added a check in
dependencyCheck()
for unused variables and prints them outLet's gooo!
I think where we print it out, or run through the check is important. That or I have yet to
touch(Variable)
in the following case:As this reports 1 unused variable, but that is NOT true.
I think I am doing this stuff too early?
Problem demystified 🔎
I found it, we use a seperate
DNodeGenerator
for the functions. We need some over-arching mechanism to group these altogether. Perhaps, placing the touching mechanism in theTypeChecker
as a place-of-precense that both seperate instances ofDNodeGenerator
can then touch on.I got this implemented and it works!
Compiler integration added with a config variable
🧠 Ideation: Variable usage checkerto ⚡ Feature: Variable usage checkerUnit tests now added ✅
Docs done
This is done, we should be able to merge soon.
Added GitHub pipelines ✅
Fixed warning message typo ✅
I want to get this done-and-klaar tomorrow.
Not doing array referncing in this one, will do a seperate PR for that.
Merging...
Resolving a conmflict...
Resolved ✅
Actually resolved ... 🤡
Merged ✅