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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request][move-compiler-v2] Lambda Lifting needs to handle modified free variables #13221

Open
brmataptos opened this issue May 7, 2024 · 0 comments
Labels
compiler-v2 enhancement New feature or request stale-exempt Prevents issues from being automatically marked and closed as stale

Comments

@brmataptos
Copy link
Contributor

brmataptos commented May 7, 2024

馃殌 Feature Request

We can't enable lambda lifting because some of our tests have free variables in lambda functions.

To handle mutated free variables in lambdas, we do an additional prepass
that transforms turns modified free variables into use of a &mut free variable. A minimal
transformation is as follows:

|x| { c = x; e }
===>
{ let ac = &mut c; |x| { let c = move *ac; let res = { c = x; e }; *ac = move c; res } }

after which, the lambda has no mutated free variables and can be replaced by Closure(lifted, ac).

Now, what borrow analysis can do with that remains to be seen. We may want to do something
special if the lambda already uses &mut c for free variable c.

@brmataptos brmataptos added enhancement New feature or request compiler-v2 labels May 7, 2024
@sausagee sausagee added the stale-exempt Prevents issues from being automatically marked and closed as stale label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-v2 enhancement New feature or request stale-exempt Prevents issues from being automatically marked and closed as stale
Projects
Status: 馃憖 In review
Development

No branches or pull requests

2 participants