Skip to content

Unexpected behavior with indentation #9790

Closed
@tgodzik

Description

@tgodzik

Minimized code

A sample like this compiles fine:

object A:
   def fn: Unit =
    if true then
  println(1)
    else
  println(2)

but this one does not:

object A:
   def fn: Unit =
    if true then
  println(1)
  println(1)
    else
  println(2)

This is most likely due to one being a single statement and the other one is treated as a block, but this is a bit of an incoherent behavior and could lead to hard to spot errors.

Expectation

Then should require a proper increasing indentation and both examples should fail.

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