Skip to content

Add a missing case to the lambda lifting transformation#6093

Merged
aryairani merged 3 commits intotrunkfrom
fix/bad-float
Jan 7, 2026
Merged

Add a missing case to the lambda lifting transformation#6093
aryairani merged 3 commits intotrunkfrom
fix/bad-float

Conversation

@dolio
Copy link
Contributor

@dolio dolio commented Jan 6, 2026

This PR fixes an oversight in the lambda lifter.

The first step of the process is to enclose terms that will be floated, so that they take their local references as arguments. We avoid adding arguments for references that will become part of the overall let-rec. However, this step was missing that lets could shadow the let-rec variables, so it would avoid enclosing these shadowing variables.

For instance, in code of the form

foo x =
   foo = ...
   bar y = ... foo ...

bar would not have foo enclosed, even though its foo reference is the inner one, not the top level.

Fixes #5889, which was caused by the test using a result variable, and the test process tweaking the code to use result to refer to the overall test result (I think).

dolio added 2 commits January 6, 2026 16:43
The encloser was not keeping track of the fact that `x` in

    x = <binding>
    <body>

will not be floated, and will shadow let-rec variables in <body>,
so we need to remove `x` from the variables to avoid enclosing.
@aryairani
Copy link
Contributor

Nice

Copy link
Contributor

@aryairani aryairani left a comment

Choose a reason for hiding this comment

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

passed CI with moderate effort 💪

@aryairani aryairani merged commit eb8a00c into trunk Jan 7, 2026
1 check passed
@aryairani aryairani deleted the fix/bad-float branch January 7, 2026 23:44
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.

Infinite recursion in a test with a bounded loop

2 participants