Make tuple unpack feature from -source:future become default?

While working on some ZIO code, I started investigating a way to directly unpack tuples in a for comprehension as “better-monadic-for” does and found that -source:future already allows this.

I found an issue (Decide what `future` behavior should be enabled in 3.3 · Issue #16334 · lampepfl/dotty · GitHub) that started this discussion but didn’t had a definition on which features should become default. The tuple unpacking is under the “refutable pattern binding” and was added in Emit strict pattern binding warnings by default · lampepfl/dotty@0bddf1b · GitHub.

What would it take to make this into the next Scala version, whether it’s 3.3 which is LTS or the next minor (3.4).

A sample of this can be seen at Scastie - An interactive playground for Scala. and discussed in ZIO’s issue retrieve a tuple directly in a for comprehension with ZIO? · Issue #2761 · zio/zio · GitHub.

Thanks

3 Likes

I’ve submitted the PR Make direct tuple assignment work by default in 3.4 by carlosedp · Pull Request #18606 · lampepfl/dotty · GitHub to address this.

I’d appreciate feedback and guidance if anything requires changes or improvements like some specific test.

1 Like

As a followup, @bishabosha pointed-out he was already working on this in the PR below. It’s pretty much done and passing all tests.

Ref. make refutable patterns an error in 3.4 by bishabosha · Pull Request #16665 · lampepfl/dotty · GitHub

I was very surprised and confused that it wasn’t the default when upgrading a Scala 2 project which was using better-for.

Happy to say that @bishabosha PR In 3.4 make refutable patterns in a for comprehension an error by bishabosha · Pull Request #18842 · lampepfl/dotty · GitHub have been merged and this will be available as default on Scala 3.4.

I’ve uploaded a sample gist that runs with scala-cli and the latest 3.4 Nightly works fine!

1 Like