scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

misleading compiler message for `:` with `-no-indent` flag

Open unkarjedy opened this issue 3 years ago • 1 comments

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:

  1. indented definition IS actually provided: def foo is the one
  2. 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...

unkarjedy avatar May 12 '21 12:05 unkarjedy

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

hartmut27 avatar Jul 23 '22 23:07 hartmut27

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.

yuriy-yarosh avatar Oct 15 '22 19:10 yuriy-yarosh