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

Under betterFors don't drop the trailing map if it would result in a different type (also drop _ => ()) #22619

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

KacperFKorban
Copy link
Member

closes #21804

@KacperFKorban KacperFKorban marked this pull request as ready for review February 19, 2025 12:34
then gen.expr // avoid a redundant map with identity
else Apply(rhsSelect(gen, mapName), makeLambda(gen, body))
&& gen.checkMode != GenCheckMode.Filtered // results of withFilter have the wrong type
&& (deepEquals(gen.pat, body) || deepEquals(body, Tuple(Nil)))
Copy link
Contributor

@odersky odersky Feb 20, 2025

Choose a reason for hiding this comment

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

Might factor out the next three lines and use in a method like markTrailingMap(gen, body). Then that can be re-used below.

@odersky odersky assigned KacperFKorban and unassigned odersky Feb 20, 2025
&& deepEquals(gen.pat, body)
then gen.expr // avoid a redundant map with identity
else Apply(rhsSelect(gen, mapName), makeLambda(gen, body))
&& gen.checkMode != GenCheckMode.Filtered // results of withFilter have the wrong type
Copy link
Contributor

Choose a reason for hiding this comment

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

This is non-standard indentation, but I'd tend t leave it in to be able to judge better how it looks.

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.

betterFors trailing map elimination can change the resulting type
3 participants