Skip to content

Compile error defining a class in the empty package with a leading space #8606

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
dwijnand opened this issue Mar 25, 2020 · 0 comments
Closed

Comments

@dwijnand
Copy link
Member

minimized code

 class A {}
@FunctionalInterface class B

Compilation output

-- Error: f1.scala:2:0 ---------------------------------------------------------
2 |@FunctionalInterface class B
  |^
  |end of statement expected but '@' found
1 error found

expectation

Compiles cleanly. Dropping the space fixes it. Or declaring it's in a package.

You can use any annotation.

Without the curly brackets the errors are on later parts:

 class A
@FunctionalInterface class B
-- Error: f3.scala:2:21 --------------------------------------------------------
2 |@FunctionalInterface class B
  |                     ^^^^^
  |                     end of statement expected but 'class' found
-- [E040] Syntax Error: f3.scala:2:27 ------------------------------------------
2 |@FunctionalInterface class B
  |                           ^
  |                           ';' expected, but identifier found
2 errors found

Using HEAD of master:

$ dotc -version
Dotty compiler version 0.24.0-bin-SNAPSHOT-git-68e2023 -- Copyright 2002-2020, LAMP/EPFL
anatoliykmetyuk added a commit that referenced this issue Mar 26, 2020
Fix #8606: Tweak newline insertion criterion
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

1 participant