-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Variable capture in closures is too restrictive #8338
Comments
cc #2202 and @nikomatsakis |
Triage; no change; I imagine this could be a bit harder with unboxed closures (since closures then have a more transparent representation, with less magic). |
I think this will never be fixed. In general, we model closures in the compiler and in the language as a kind of advanced sugar for things you could type yourself, and the fact is that the captured variable is being bundled up into the environment when it is not initialized. Nominating for closure. |
Decided to just close. |
This program
Output
error: capture of possibly uninitialized variable: 'x'
, even though as an lvalue there is no danger of uninitialized usage. Could the compiler be made smarter about this? Maybe add a rule that if the variable first appearance in the closure is as an lvalue it's ok.The text was updated successfully, but these errors were encountered: