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

Shadow variables inside loops and if statements #387

Merged
merged 6 commits into from
May 12, 2024
Merged

Shadow variables inside loops and if statements #387

merged 6 commits into from
May 12, 2024

Conversation

laurentlb
Copy link
Owner

@laurentlb laurentlb commented May 11, 2024

In the past, we used the shadowing mechanism only when entering functions. Now, we do if in loops and if statements too.

Note that scopes often don't start at the blocks (curly braces). In a function, arguments are part of the function body scope. In a for-loop, the init declaration is part if the for-loop body too, even if there are curly braces. For this reason, we don't apply shadowing at the block level.

Fixes #382

In the past, we used the shadowing mechanism only when entering functions. Now, we do if in for loops and if statements too.

Note that scopes often don't start at the blocks (curly braces). In a function, arguments are part of the function body scope. In a for-loop, the init declaration is part if the for-loop body too, even if there are curly braces. For this reason, we don't apply shadowing at the block level.
@laurentlb laurentlb changed the title Shadow variables inside for loops and if statements Shadow variables inside loops and if statements May 11, 2024
@laurentlb laurentlb merged commit c526918 into master May 12, 2024
1 check passed
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.

Renaming: allow shadowing inside local blocks
2 participants