Scala 3.9.0 release thread

Scala 3.9.0-RC6 is now available for testing

4 Likes

I haven’t found any errors this time around!

It is annoying that - 25 and -25.toString are indistinguishable by message (unless -explain is on). The former is always syntactically dubious–possibly a typo but also likely an error. The latter is a safety for people who don’t think number literals are primary and tokenizing and operator precedence is secondary (i.e. a heads up for people who have been programming too long to retain the natural naive interpretation that 25 and -25 are just numbers and behave the same, but not long enough to know that for Scala 25 and -25 do in fact behave the same syntactically).

I assume the message can be tweaked for 3.9.1 or later in a way that allows -Wconf to discriminate between them, so it need not be bikeshedded now.

I missed the distinction (brain not fully engaged) but probably there will be further opportunity to refine the message when they fix Character Literals:

scala> -42.toString
1 warning found
-- [E028] Syntax Warning: ------------------------------------------------------
1 |-42.toString
  |^
  |Illegal literal
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | Available literals can be divided into several groups:
  |  - Integer literals: 0, 21, 0xFFFFFFFF, -42L
  |  - Floating Point Literals: 0.0, 1e30f, 3.14159f, 1.0e-100, .1
  |  - Boolean Literals: true, false
  |  - Character Literals: 'a', 'A', '
  | '
  |  - String Literals: "Hello, World!"
  |  - null
   -----------------------------------------------------------------------------
val res0: String = "-42"

which was intended more literally:

| - Character Literals: 'a', '\u0041', '\n'

The fix to warn for -42L.abs is not on 3.9 LTS.

It occurred to me to wonder if -rewrite works:

scala> -42.toString
1 warning found
[patched file <incomplete-handler>]
[patched file rs$line$1]
-- [E028] Syntax Warning: ------------------------------------------------------
1 |-42.toString
  |^
  |Illegal literal
  |
  | longer explanation available when compiling with `-explain`
val res0: String = "-42"