Skip to content

clarify leading infix example #12970

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

Open
som-snytt opened this issue Mar 20, 2024 · 1 comment
Open

clarify leading infix example #12970

som-snytt opened this issue Mar 20, 2024 · 1 comment
Milestone

Comments

@som-snytt
Copy link

Questions are not bug reports

Even if the bug is a head-scratcher?

Reproduction steps

Scala version: 2.13.13 vs 3.4.1

class C {
  def ??? (i: Int): Int = i+1
}
object Test extends App {
  val ??? = 6
  val c = new C
  val x =
    c
    ???
    ??? match { case i => i }

  val y =
    "hi"
    +
    "bye" match { case "bye" => "bi" case _ => "huh" }
  println(y)
  println(x)
}

Problem

As rehashed at scala/scala3#19763

x is 6 in Scala 3 where leading infix is rejected; 7 in Scala 2 which accepts it.

It would be nice to either forward-port the behavior (and specify it) or, since leading infix is now behind -Xsource-options and no one will use it, let the sleeping dog lie.

@som-snytt
Copy link
Author

The possible tweak is that the old suggestion to insert a semi is not leading-infix aware. (The semi would go between the lines.)

mlo.scala:10: error: value *= is not a member of Int
possible cause: maybe a semicolon is missing before `value *=`?
  Expression does not convert to assignment because receiver is not assignable.
    `a` *= 6
        ^

@SethTisue SethTisue added jdk24 and removed jdk24 labels Nov 6, 2024
@SethTisue SethTisue added this to the Backlog milestone Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants