scala3
scala3 copied to clipboard
misleading compiler message for `:` with `-no-indent` flag
Compiler version
scalaVersion := "3.0.0-RC3",
scalacOptions ++= Seq("-no-indent")
Minimized code
create simple file with indentation-based syntax for template definition of package definition
trait A:
def f: Int
or
package bbb:
trait A
Output
Compile the code, see the compiler message:
indented definitions expected, def found def foo = 42
The message misleads:
- indented definition IS actually provided:
def foo
is the one - indented definition SHOULD NOT even be expected, because flag
-no-indent
is provided
Expectation
The compiler should say something like
:
is not recognized
OR
{ / extends / etc... expected
OR
:
is not supported with-no-indent
flag
OR something else...
I've encountered the error message after migration to Scala 3, when using indentation syntax:
indented definitions expected, ... found
.
I could fix it by commenting out the sbt-scala3-migrate
plugin in project/plugins.sbt
.
...
// addSbtPlugin("ch.epfl.scala" % "sbt-scala3-migrate" % "0.5.1")
...
Then reload sbt project, then recompile project.
The error message indented definitions expected, ... found
disappeared.
I hope this helps :-)
Ref.: ID_RPWLKJQM4JSM
Started sbt-typelevel
project with scala3 as the base scala version, for some reason getting the same error in the common sbt-crossproject setup for automerge-scala
So
val Scala2Version = "2.13.10"
val Scala3Version = "3.2.0"
ThisBuild / crossScalaVersions := Seq(Scala2Version, Scala3Version)
ThisBuild / scalaVersion := Scala3Version
Gives me indented definitions expected, ... found
errors
while
val Scala3Version = "3.2.0"
ThisBuild / scalaVersion := Scala3Version
...does not
So, it's something sbt-crossproject
related.