Skip to content

Dotty fails to compile with } and else on the same line #7421

Closed
@Mocuto

Description

@Mocuto

The following style if/else statements are failing to compile on Dotty version 0.19.0-RC1

minimized code

object Main {

  def main(args: Array[String]): Unit = {
    if (args.length > 0)
      {
        println(args)
      } else {
      println("Hello world!")
    }
  }
}

expectation

This should compile as it does in Scala 2.12

actual

This fails to compile:

[error] -- Error: D:\code\dotty-cont\dottyplayground\src\main\scala\Main.scala:7:8 -----
[error] 7 |      } else {                                                                                               [error]   |        ^^^^                                                                                                 [error]   |        end of statement expected but else found                                                             [error] -- [E040] Syntax Error: D:\code\dotty-cont\dottyplayground\src\main\scala\Main.scala:7:13
[error] 7 |      } else {                                                                                               [error]   |             ^                                                                                               [error]   |             ';' expected, but '{' found                                                                     [error] two errors found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 5 s, completed Oct 13, 2019 9:12:30 PM

The workaround is simple but this behavior is unexpected.

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