Skip to content

produce a compiler warning/error for a code block which goes as a first indentation region statement #12421

Open
@unkarjedy

Description

@unkarjedy

Consider the example below.
Note that f1 has an indentation region with a code block as a first statement.
IMO such syntax is quite misleading and it's easy to be confused.
Even if you use indentaion-based syntax f1 very much looks like a method definition with some badly-indented println(2) (like in f2)
It's especially easy to misread if there is a new line after the code block.
If such code exists in some project one could think that it's something wrong with the formatting and unindent println(2) breaking the semantics

object O:
  def f1(): Unit =
    {
      println(1)
    }

    println(2)

  def f2(): Unit =
  {
    println(3)
  }
    println(4)
  
  def f3(): Unit =
  {
    println(5)
  }
  println(6)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogNo work planned on this by the core team for the time being.stat:needs info

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions