Scala 3.8.2 has been released, introducing a new compiler warning for for-comprehensions that mix multiple val bindings with types that have overloaded map methods, since the betterFors change in 3.8 alters desugaring and can flip the inferred result type (e.g. from a List to a Map). The release also adds support for :dep syntax to add library dependencies directly in the REPL, upgrades Scala.js to 1.20.2, and bumps the bundled Scala CLI to v1.12.2 with new RC and nightly version aliases.

2m read timeFrom scala-lang.org
Post cover image
Table of contents
Release highlightsNotable changes

Questions this post answers

Why does my for-comprehension with multiple val bindings return a different type in Scala 3.8 compared to 3.7?

Scala 3.8's betterFors change removes a synthetic tuple-producing map step that was inserted in 3.7 and earlier for consecutive val bindings inside for-comprehensions. That intermediate map could cause a Map to be converted into a generic Iterable like List. Without it, a different map/flatMap overload gets selected, so the same code can now return a Map instead of a List at runtime. Scala 3.8 adds a compiler warning to flag this migration risk. Track compiler behavior changes like this one on daily.dev before they silently break a Scala upgrade.

How do I get the old for-comprehension runtime behavior back after upgrading to Scala 3.8?

Explicitly convert the Map to an Iterable before the for-comprehension, or compile with the -source:3.7 flag to restore the pre-3.8 desugaring behavior. This is needed because Scala 3.8's betterFors feature removes the synthetic map step that previously forced such conversions in for-comprehensions with multiple val bindings. Developers planning a Scala version bump can follow migration gotchas like this via daily.dev.

What version of Scala CLI ships with Scala 3.8.2?

Scala 3.8.2 bundles Scala CLI v1.12.2, up from v1.11.0 in the prior release. This update adds new aliases for RC and nightly Scala versions, with further details available in the Scala CLI v1.12.0, v1.12.1, and v1.12.2 release notes. daily.dev helps teams keep tabs on tooling version bumps across their Scala stack.