Fix lambda normalization by renumbering parameters from innermost scope#568
Fix lambda normalization by renumbering parameters from innermost scope#568rishi-jat wants to merge 11 commits into
Conversation
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors lambda normalization in LightTypeTagRef by removing the FAKE parameter substitution approach and implementing a depth-based renumbering scheme. The new approach assigns depth 0 to innermost lambda parameters and negative depths (-1, -2, etc.) to outer scopes, making the normalized form suitable as the primary representation.
Key changes:
- Replaces
makeFakeParamsandlambdaFakeParamDepthwith a recursivenormalizefunction - Implements depth renumbering based on lambda nesting level
- Removes
normalizedParamsas it's no longer needed with the new approach
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
|
@pshirshov @neko-kai , PR is ready for review please have a look when you get a chance. Thanks! |
|
You should at least add the test from the issue itself to check the new normalized forms |
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
|
@neko-kai please have a look when you get a chance. Thanks! |
|
@pshirshov @neko-kai, can you please review the PR ? Thanks! |
|
/cc @pshirshov |
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
|
Could you add some tests for string representations of the renormalized lambdas? |
will do asap. Thanks! |
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
|
hi @pshirshov @neko-kai , The test now covers a real nested lambda case, verifies that FAKE_* parameters are gone, and asserts that outer-scope references are rendered with the correct depth in the output. All tests pass on Scala 2.12, 2.13, and 3. Please let me know if you’d like the assertion to be stricter or if there’s another case you want covered. |
|
/cc @neko-kai |
|
@neko-kai @pshirshov , did you get a chance to review the PR ? Thanks! |
/claim #379
Normalize lambda parameter depths in LightTypeTagRef.Lambda
by recursively renumbering parameters from the innermost scope outward.
Normalization is applied locally during lambda construction and avoids
any changes to global parameter numbering or application logic.
Implements the approach suggested by @pshirshov.
Closes #379