Skip to content

Add support for mutable variables#462

Merged
Kijewski merged 3 commits intoaskama-rs:masterfrom
GuillaumeGomez:mutable-vars
Jun 1, 2025
Merged

Add support for mutable variables#462
Kijewski merged 3 commits intoaskama-rs:masterfrom
GuillaumeGomez:mutable-vars

Conversation

@GuillaumeGomez
Copy link
Copy Markdown
Collaborator

Part of #452.

For now it only supports variables declared as mutable, not destructuring. Not sure if we want to go down this road or not but if we do, let's do it in a follow-up PR.

@GuillaumeGomez GuillaumeGomez requested a review from Kijewski May 25, 2025 13:50
@Kijewski
Copy link
Copy Markdown
Member

I think we should track if a variable was allocated with mut, so a subsequent {% set var = … %} reassigns the value instead of shadowing it. Or would you rather add this feature in a subsequent PR?

@GuillaumeGomez
Copy link
Copy Markdown
Collaborator Author

Hum... I wonder if we shouldn't just keep the shadowing. If the new variable doesn't have the same type, it would fail compilation after all. Shadowing and updating the variable value are kinda the same no?

@Kijewski
Copy link
Copy Markdown
Member

Kijewski commented Jun 1, 2025

Yeah, makes sense. Also that keeps it simple, and I guess I don't really see a dire need for re-assignable variables.

@Kijewski Kijewski merged commit 6010cd3 into askama-rs:master Jun 1, 2025
39 checks passed
@GuillaumeGomez GuillaumeGomez deleted the mutable-vars branch June 1, 2025 16:46
@Kijewski Kijewski mentioned this pull request Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants