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

Fixes #3824, fixes #19154, and hopefully #24094. Re-applies #23787. #24316

Merged
merged 3 commits into from
Oct 18, 2024

Conversation

yglukhov
Copy link
Member

@yglukhov yglukhov commented Oct 16, 2024

The first commit reverts the revert of #23787.
The second fixes lambdalifting in convolutedly nested closures/closureiters. This is considered to be the reason of #24094, though I can't tell for sure, as I was not able to reproduce #24094 for complicated but irrelevant reasons. Therefore I ask @jmgomez, @metagn or anyone who could reproduce it to try it again with this PR.

I would suggest this PR to not be squashed if possible, as the history is already messy enough.

Some theory behind the lambdalifting fix:

  • A closureiter that captures anything outside its body will always have :up in its env. This property is now used as a trigger to lift any proc that captures such a closureiter.
  • Instantiating a closureiter involves filling out its :up, which was previously done incorrectly. The fixed algorithm is to use "current" env if it is the owner of the iter declaration, or traverse through :ups of env param until the common ancestor is found.

Copy link
Collaborator

@metagn metagn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to my understanding, maybe @jmgomez can confirm the current langserver works as expected with this in case my reproduction isn't enough

@Araq Araq added the merge_when_passes_CI mergeable once green label Oct 17, 2024
@Araq Araq merged commit 5fa96ef into nim-lang:devel Oct 18, 2024
19 checks passed
@Araq
Copy link
Member

Araq commented Oct 18, 2024

Ooops, squashed the commits, sorry.

Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 5fa96ef

Hint: mm: orc; opt: speed; options: -d:release
175169 lines; 8.294s; 655.312MiB peakmem

@yglukhov yglukhov deleted the fix-closureiters2 branch October 18, 2024 09:03
@ZoomRmc
Copy link
Contributor

ZoomRmc commented Oct 18, 2024

Yay, a negative LoC PR (not counting tests)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge_when_passes_CI mergeable once green
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants