-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Items with 'lexical' scope have poor scoping #23880
Comments
It's not an error anymore: http://is.gd/CKvJn3 |
Ah curses, that isn't an error. Here's another go:
In this case the |
classifying as "just a bug", P-high, not 1.0. Actually leaving as P-backcompat-lang, to represent the fact that this can lead to programs being accpeted that shoudl be rejected. So we will keep that tag as is. But still not 1.0 blocker. |
triage: P-medium This has been sitting for a while and we don't expect immediate action, though hopefully a refactoring of resolve would lead to this being fixed. |
This fixes a bug in which items in a block are shadowed by local variables and type parameters that are in scope. It is a [breaking-change]. For example, the following code breaks: ```rust fn foo() { let mut f = 1; { fn f() {} f += 1; // This will now resolve to the function instead of the local variable } } ``` Any breakage can be fixed by renaming the item that is no longer shadowed.
This fixes #23880, a scoping bug in which items in a block are shadowed by local variables and type parameters that are in scope. After this PR, an item in a block will shadow any local variables or type parameters above the item in the scope hierarchy. Items in a block will continue to be shadowed by local variables in the same block (even if the item is defined after the local variable). This is a [breaking-change]. For example, the following code breaks: ```rust fn foo() { let mut f = 1; { fn f() {} f += 1; // This will resolve to the function instead of the local variable } }
E.g.,
Is an error, but shouldn't be, because the
bar
method hides the locally declaredbar
function insidefoo
.I think this is a bug, so it shouldn't be on any milestone, but nominating just in case.
The text was updated successfully, but these errors were encountered: