SIP-62 better for `dropForMap` phase bug · Issue #24673 · scala/scala3 · GitHub fixed dropping the final map call in for comprehensions for side effecting functions, however, I believe a case was left out: when the final map call has a using clause, and resolving that implicit results in a side effect.
I noticed this when using traces with ZIO. ZIO maps ask for a Trace, and default to generating one when a more specific one is not present. Prior to upgrading to 3.9 from 3.7 (I know better-fors is a 3.8 feature), if a final map in a for comprehension produced a failing effect, the generated trace would include a frame for that map call, whereas after the upgrade, it does not.
This scastie demonstrates the difference in behavior when run with 3.7 versus 3.9:
I’m curious if this is intended or if this is another edge case for keeping the final map? If intended, could we either re-evaluate that decision or provide a mechanism to force keeping the map call?