Scala 3.10.1 release thread

First RC of Scala 3.10.1 is now available for public tests!

Highlights of the release

  • Bump Scala CLI to 1.18.0 (was 1.17.1) #27255
  • Implement SIP-77: Method Block End Markers as experimental #24251

For full list of changes, bugfixes and improvements see:

The stable release is planned no earlier than 11th November

A surprise to be sure, but a welcome one.

class FooSuite extends munit.FunSuite:
  
  test("property a"):
    assertEquals(2 * 2, 4)
  end test
5 Likes

Stable Scala 3.10.1 is now available!

5 Likes

I am getting new compilation errors (upgrading from 3.10.0), but this is not mentioned on the release page (if it is intentional, can it be mentioned?):

[error] -- [E007] Type Mismatch Error: /Users/scalafan/Documents/game-scalajs/actors/src/main/scala/models/profile/InitialsAvatar.scala:29:36 
[error] 29 |            g.setPaint(Color.getHSBColor(hue, 0.9, value))
[error]    |                                              ^^^
[error]    |                                              Found:    (0.9d : Double)
[error]    |                                              Required: Float

Sorry, it’s an unexpected regression that slipped through as side effect of other changes.

The Float fix (#27194) is not in 3.10.1, it was missed in the backports. It would ship in 3.10.2.

Scala 3 has long accepted an unsuffixed decimal where a Float is expected, so Color.getHSBColor(hue, 0.9, value) compiled on 3.10.0. #27124 put that conversion behind a feature flag. Without the flag, 0.9 stays a Double, and 3.10.1 reports Found: (0.9d : Double), Required: Float. The same happens for values that fit in a Float exactly, such as 1.0 and 5.5.

That matches Scala 2, where val f: Float = 0.9 is already an error, but the alignment was accidental. It landed in a patch release and broke existing Scala 3 code. #27194 restores the 3.10.0 behavior: an unsuffixed decimal is typed as Float when Float is expected, and the compiler warns when the value is not exactly representable as a Float.

Until 3.10.2, write the literal with an f suffix, such as 0.9f.

2 Likes

To be explicit, the feature flag is -language:experimental.genericNumberLiterals. That is probably a benign workaround for 3.10.1.

The alignment with Scala 2 was intended, per the ticket, but the alternative approach would be to align (and warn) under 3.0-migration, since it is really a migration issue.

➜  ~ scala-cli run --server=false -e 'println(0xFFFFFFFF: Long); println(0xFFFFFFFF.toLong)' -S 3.10.0
4294967295
-1
➜  ~ scala-cli run --server=false -e 'println(0xFFFFFFFF: Long); println(0xFFFFFFFF.toLong)' -S 3.10.1
-1
-1
➜  ~ scala-cli run --server=false -e 'println(0.1: Float); println(0.1: Double)' -S 3.10.1
-- [E007] Type Mismatch Error: /tmp/5442975884143809025/.scala-build/5442975884143809025_e082bc2625-e8fcfd84f5/src_generated/main/snippet.scala:7:8
7 |println(0.1: Float); println(0.1: Double)
  |        ^^^
  |        Found:    (0.1d : Double)
  |        Required: Float
  |
  | longer explanation available when compiling with `-explain`
1 error found
Compilation failed
➜  ~ scala-cli run --server=false -e 'println(0.1: Float); println(0.1: Double)' -S 3.10.1 -language:experimental.genericNumberLiterals
0.1
0.1
➜  ~ scala-cli run --server=false -e 'println(0xFFFFFFFF: Long); println(0xFFFFFFFF.toLong)' -S 3.10.1 -language:experimental.genericNumberLiterals
-- [E167] Lossy Conversion Warning: /tmp/8364946534215237982/.scala-build/8364946534215237982_f8d0da7240-86378d2cdf/src_generated/main/snippet.scala:7:8
7 |println(0xFFFFFFFF: Long); println(0xFFFFFFFF.toLong)
  |        ^^^^^^^^^^
  |Literal produces a different Long value compared to conversion.
  |Write `.toLong` for conversion, or use `L` suffix to silence this warning.
1 warning found
4294967295
-1