Skip to content

End marker before leading infix is non-documentary #15011

Open
@som-snytt

Description

@som-snytt

Compiler version

Scala code runner version 3.2.0-RC1-bin-SNAPSHOT-git-8600c3d -- Copyright 2002-2022, LAMP/EPFL

Minimized code

def f(b: Boolean) =
  if b then 42 else 17
  + 27

def g(b: Boolean) =
  if b then 42 else 17
  end if
  + 27

Similar example from the convo:

def f =
  for res <- List(1, 2) yield
    if res == 1 then "one!" else "two!"
    end if
  + "end"

Output

    def f(b: Boolean): Int = if b then 42 else 17.+(27)
    def g(b: Boolean): Int =
      {
        if b then 42 else 17
        27.unary_+
      }

or

    def f: List[String] =
      List.apply[Int]([1,2 : Int]*).map[String](
        {
          def $anonfun(res: Int): String = (if res.==(1) then "one!" else "two!").+("end")
          closure($anonfun)
        }
      )

Expectation

General expectation is that end markers merely document indentation regions.

If an end marker alters parsing, I expect a warning or error.

Also, I expect minimal feelings of confusion. Like a joke, if you have to explain it, it's no longer funny.

Noticed at https://discord.com/channels/632150470000902164/632628644035952680/967050718450155590

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