Skip to content

parser error: multiple if-guards on the same line in for-comprehensions #12323

Closed
scala/scala
#9456
@unkarjedy

Description

@unkarjedy

using Scala 2.13.4

According to scala syntax (https://www.scala-lang.org/files/archive/spec/2.13/13-syntax-summary.html)

Generator ::=  Pattern1 ‘<-’ Expr {[semi] Guard | semi Pattern1 ‘=’ Expr}

several guards on the same line is a valid code.
But unfortunately, if you place several guards on the same line, starting from a new line, a compilation error occurs.

for {
  x <- 1 to 5 if true if true
} yield x

for {
  x <- 1 to 5 if true
  if true
} yield x

for {
  x <- 1 to 5
  if true if true
} yield x

for {
  x <- 1 to 5
  if true
  if true
} yield x

image

related issue: https://youtrack.jetbrains.com/issue/SCL-13220

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions