Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End marker before leading infix is non-documentary #15011

Open
som-snytt opened this issue Apr 22, 2022 · 0 comments
Open

End marker before leading infix is non-documentary #15011

som-snytt opened this issue Apr 22, 2022 · 0 comments

Comments

@som-snytt
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants