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

Renaming: allow shadowing inside local blocks #382

Closed
laurentlb opened this issue May 9, 2024 · 0 comments · Fixed by #387
Closed

Renaming: allow shadowing inside local blocks #382

laurentlb opened this issue May 9, 2024 · 0 comments · Fixed by #387

Comments

@laurentlb
Copy link
Owner

We currently do shadowing in one case: inside a function, when a global symbol is not used.
We could do it in more cases, i.e. each time we enter a new scope (if-body, for-body, etc.).

For example, we could do:

int x = ...;
for(int i = 0; i < 10; i++) {
  int x = ...; // if the outer x is not used inside the for-loop
}
laurentlb added a commit that referenced this issue May 12, 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
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 a pull request may close this issue.

1 participant