Skip to content

for comprehension loses backticks when desugaring to val? #11533

Closed as not planned
@jducoeur

Description

@jducoeur

This arose from this thread on Scala Users.

Take the following code (working fiddle, Scala 2.12):

val `P(X|C)`=3

println(`P(X|C)`)

val x = for {
  `F(Y|Z)` <- Option(3)
  `P(X|C)` <- Option(6)
  `A(B|C)` = 4  // fails here
}
  yield `P(X|C)`
  
println(x)

Everything compiles for me except the specified line, which is getting the error:

ScalaFiddle.scala:8: error: not found: value A(B|C)
    `A(B|C)` = 4
    ^

All of this suggests to me that something's a bit weird with backtick'ed identifiers when desugaring to a val. The desugars to flatMap and map appear to work, but the one to val doesn't...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions