Skip to content

Misindent imports produces a confusing error #9992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mlachkar opened this issue Oct 13, 2020 · 1 comment
Closed

Misindent imports produces a confusing error #9992

mlachkar opened this issue Oct 13, 2020 · 1 comment
Assignees

Comments

@mlachkar
Copy link
Contributor

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.

@som-snytt
Copy link
Contributor

Similar to #9515 where the error does not indicate where indentation was established.

@odersky odersky self-assigned this Oct 19, 2020
odersky added a commit that referenced this issue Nov 17, 2020
Fix #9992: Reset toplevel indent region width on left indent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants