Skip to content

Wrong rewrite of misaligned case #20003

Open
@OndrejSpanel

Description

@OndrejSpanel

Compiler version

3.4.1-RC2

Minimized code

Use -indent -rewrite on:

@main
def main: Unit = {

  val x = 0
  x match {
    case 0 =>
  case 1 =>
    case 2 =>
  }
}

Output

@main
def main: Unit =

  val x = 0
  x match
    case 0 =>
  case 1 =>
    case 2 =>

Error:

C:\Dev\Sandbox\src\main\scala\Main.scala:7:3
unindent expected, but 'case' found
case 1 =>

Expectation

The output of "-indent", "-rewrite" should compile without errors

Note

While code like this is unlikely to be written intentionally, it can appear when ignoring whitespace changes while merging in git.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions