Skip to content

Add scopes to AssignVariableName#3416

Merged
siegfriedpammer merged 6 commits intomasterfrom
variable-naming
Mar 21, 2025
Merged

Add scopes to AssignVariableName#3416
siegfriedpammer merged 6 commits intomasterfrom
variable-naming

Conversation

@siegfriedpammer
Copy link
Member

Link to issue(s) this covers: #1572, #1956, #2439, #2694

Needs more thorough testing on larger code bases, but it will be hard to verify the results.

@tamlin-mike @yyjdelete @greenozon

@dgrunwald I suspect that the "allow shadowing of names in local functions / lambdas" language feature could be implemented in ILSpy by making sure that no variables in the ILFunction.CapturedVariables list have the same name as any local variable or parameter? The changes in this PR only introduce the concept of a scope per ILFunction, so parameters of "independent" lambdas such as list.Where(x => x > 5).Select(x => x * 2) are allowed even without the setting, but nested lambdas that "shadow" a lambda parameter, but don't use any variable from a parent scope are not allowed right now.

@siegfriedpammer siegfriedpammer merged commit a40a033 into master Mar 21, 2025
9 checks passed
@siegfriedpammer siegfriedpammer deleted the variable-naming branch July 8, 2025 05:17
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.

1 participant