Skip to content

-Wunused gives false positives for generator value with a guard #16925

Closed
@rochala

Description

@rochala

Compiler version

3.3.1-RC1-bin-20230213-8c616bf-NIGHTLY

Minimized code

//> using scala "3.3.1-RC1-bin-20230213-8c616bf-NIGHTLY"
//> using options "-Wunused:all"

@main
def hello =
  for {
    i <- 1 to 2 if true
    _ = println(i)
  } yield ()

Output

Compiling project (Scala 3.3.1-RC1-bin-20230213-8c616bf-NIGHTLY, JVM)
[warn] ./src/scala3/FileA.scala:8:5: unused local definition
[warn]     i <- 1 to 2 if true
[warn]     ^

Expectation

Don't report i as unused local definition

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:lintingLinting warnings enabled with -W or -Xlintitype:bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions