Skip to content

Misindent imports produces a confusing error  #9992

Closed
@mlachkar

Description

@mlachkar

Minimized code

  import scala.concurrent._

@main def main(): Unit =
  def test = ()
  test

Output

[error] -- [E018] Syntax Error: /Users/meriamlachkar/perso/dotty/src/main/scala/Show.scala:3:24 
[error] 3 |@main def main(): Unit =
[error]   |                        ^
[error]   |                        expression expected but def found
[error] -- [E080] Syntax Error: /Users/meriamlachkar/perso/dotty/src/main/scala/Show.scala:5:2 
[error] 5 |  test
[error]   |  ^^^^
[error]   |  Expected a toplevel definition
[warn] -- [E129] Potential Issue Warning: /Users/meriamlachkar/perso/dotty/src/main/scala/Show.scala:3:22 
[warn] 3 |@main def main(): Unit =
[warn]   |                      ^
[warn]   |A pure expression does nothing in statement position; you may be omitting necessary parentheses
[warn] one warning found
[error] two errors found
[error] (Compile / compileIncremental) Compilation failed

Expectation

Fixing the import indentation fixes this error.
From reading the error message, it's not clear what causes the error.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions