Track if mutable variable is ever reassigned (#595)#605
Conversation
|
Hey, first of all thank you for the contribution. I never expected that! As for the change itself, I'm a bit concerned about the Then, whenever the typechecker ends a scope, it could check which mutable variables had not been reassigned to and push them into If you have any thoughts on this approach, or want to submit a pull request to take a shot at the idea outlined above, I'll be happy to check it out. But I do want to caution against any expectations of stability in this project, as I change things day-to-day sometimes and you may get merge conflicts. |
|
Hi! First of all I do really like your project so I really wanted to contribute and help out! I also appreciate the feedback on the implementation! I really appreciate you taking the time to review the contribution :) I did just realize you're very right about the performance concerns with the I really like your suggestion about expanding the existing I may be a bit out of my element here, but here's how I'm thinking we could implement your suggestion: Create a new Modify the typechecker to populate
Update the LSP to use this information directly instead of the current I think this would improve the performance while still providing the same developer experience benefits. I think this approach aligns well with the existing architecture and would be much more efficient. I'd also like to hear your thoughts about this too! Thanks :) |
Overview
Implements issue #595 by tracking whether mutable variables are ever reassigned, providing LSP warnings and compilation optimizations.
Changes
Typechecker (projects/compiler/src/typechecker.abra)
LSP (projects/lsp/src/language_service.abra)
IR Generation (projects/compiler/src/ir.abra)
Benefits
Example
1 // Generates warning: "Variable 'x' is declared as mutable but never reassigned..."
2 var x = 10
3
4 // No warning - variable is reassigned
5 var y = 20
6 y = 30
Testing