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

Closure functions actually enclose outer-scope variables #821

Merged
merged 3 commits into from
Jul 30, 2024

Conversation

dfellis
Copy link
Member

@dfellis dfellis commented Jul 29, 2024

This fixes an issue with closures actually using variables from the outer scope by making sure they're available as owned values within the closure. This is a super trivial implementation that just clones everything from the outer scope, but it works, and appears to have the unused clones deleted during LLVMs optimization passes (probably just dropping all unused variables in their entirety?) "If it's stupid but it works..."

@dfellis dfellis self-assigned this Jul 29, 2024
src/program/microstatement.rs Fixed Show fixed Hide fixed
src/program/microstatement.rs Fixed Show fixed Hide fixed
@dfellis
Copy link
Member Author

dfellis commented Jul 30, 2024

Whelp, it doesn't quite work as-is. Now to decide if/how to reduce the set of variables to clone...

@dfellis dfellis merged commit 068949a into main Jul 30, 2024
11 checks passed
@dfellis dfellis deleted the closures-actually-enclose branch July 30, 2024 14:47
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