Skip to content
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

Added support for shadowing variables #411

Merged
merged 3 commits into from
Dec 25, 2020
Merged

Added support for shadowing variables #411

merged 3 commits into from
Dec 25, 2020

Conversation

vallentin
Copy link
Collaborator

Fixes #329

Considering that it wasn't previously possible to shadow variables. Then this qualifies as a non-breaking change, as it only extends new functionality.

  • Updated generator, specifically adding initialized to LocalMeta
  • Added test case
  • Updated book

In short, if a LocalMeta is initialized then any subsequent {% let ... %} shadows and generates a new variable. The variable is literally redefined by inserting a new one. Thereby making it possible to e.g. initialize and shadow in multiple nested branches.

To be consistent with Rust, {% let (a, b) = ... %} always shadows, and can't be used to assign (which it couldn't before either.)

@djc
Copy link
Owner

djc commented Dec 25, 2020

Looks good, just a minor question!

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.

Add support for redefining the same variable with let (just as Rust permits)
2 participants