Skip to content

Incorrect rewriting of code from significant indentation to non-significant indentation based syntax #17187

Closed
@eloots

Description

@eloots

Compiler version

3.0.2 and higher

Minimized code

I haven't managed to come up with a minimised example, but I created this repo that illustrates the issue and that pinpoints the Scala version that introduced the problem (note that I tried this a long time back with RC releases of Scala 3.0.0 and the GA release of Scala 3; that version didn't have this issue).

Output

When rewriting syntax from significant indentation based syntax to non-significant indentation based syntax, the compiler generates code where in some spots, a closing curly brace is missing. In the code provided in the linked repo, this occurs 12 times.

For example, in file src/main/scala/org/lunatechlabs/dotty/SudokuSolverMain.scala, notice the missing } for method main:

object SudokuSolverMain {

  def main(args: Array[String]): Unit = {

    val system = ActorSystem[NotUsed](Main(), "sudoku-solver-system")

    println(s"${GREEN}Hit RETURN to stop solver${RESET}")
    StdIn.readLine()
    system.terminate()
}

Expectation

The compiler should rewrite code correctly. In fact, it should be possible to go "full circle" through the different syntax version as noted in the README in the linked repo.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions