scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

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

Open klaeufer opened this issue 3 years ago • 1 comments

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

klaeufer avatar Dec 10 '22 02:12 klaeufer

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).

Gedochao avatar Aug 08 '24 06:08 Gedochao