Improve Borrow Checker to Handle Scopes and Borrow Checking #12
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.
Handle multiple immutable borrows: The
BorrowChecker
now allows multiple immutable borrows of the same variable, aligning with Rust's borrow rules. In short, no longer returns an error when a variable is immutably borrowed multiple times.Handle scopes correctly: The
BorrowChecker
now correctly handles variables declared in outer scopes when checking inner scopes. It uses a stack of scopes, each represented as a hashmap. When entering a new scope, it pushes a new hashmap onto the stack, and when leaving a scope, it pops the hashmap off the stack.Add more test cases