Skip to content

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

Closed
@dwijnand

Description

@dwijnand

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions