scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.84k stars 1.05k forks source link

REPL :type command produces unexpected error when -Xfatal-warnings compiler option is set #16494

Open klaeufer opened 1 year ago

klaeufer commented 1 year ago

Compiler version

3.2.1

Minimized code

build.sbt (tried with sbt 1.7.1 or 1.8.0 and Java 17.0.5-tem)

Compile / scalacOptions ++= Seq("-Xfatal-warnings")
$ sbt consoleQuick
scala> :type 3

Output

-- [E129] Potential Issue Error: -----------------------------------------------
1 |3
  |^
  |A pure expression does nothing in statement position; you may be omitting necessary parentheses
  |
  | longer explanation available when compiling with `-explain`

Expectation

scala> :type 3
Int
Gedochao commented 2 months ago

I noticed the error changed to a warning since 3.4.1 (and is so up till the current nightly, 3.6.0-RC1-bin-20240807-54344a1-NIGHTLY).

scala-cli -Xfatal-warnings -S 3.nightly
Downloading Scala 3.6.0-RC1-bin-20240807-54344a1-NIGHTLY compiler
Downloading Scala 3.6.0-RC1-bin-20240807-54344a1-NIGHTLY bridge
Welcome to Scala 3.6.0-RC1-bin-20240807-54344a1-NIGHTLY-git-54344a1 (17, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> :type 3
-- [E129] Potential Issue Warning: ---------------------------------------------
1 |3
  |^
  |A pure expression does nothing in statement position
  |
  | longer explanation available when compiling with `-explain`
No warnings can be incurred under -Werror (or -Xfatal-warnings)

scala> 

We still shouldn't warn here, just noting the behaviour changed (and it's now a linting/reporting bug).