Skip to content

Nothing warns about unconsumed values in for comprehension #18854

Open
@keynmol

Description

@keynmol

Compiler version

3.3.1+ (tested on nightly as well)

Minimized code

This shows several places where it works and the one where it doesn't

//> using scala 3.nightly
//> using option -Wnonunit-statement 

def method: List[Int] = List(25)

@main def repro = 
  method // WARNING here ✅
  
  val _ = for 
    x <- method 
    _ = method // Nothing here ❌
  yield x

  method.flatMap: x =>
    method.map: y=>
      method // WARNING here ✅
      List()

Output

// TODO add output here

Expectation

I expected a warning because it's a non-unit statement (?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:lintingLinting warnings enabled with -W or -Xlintarea:reportingError reporting including formatting, implicit suggestions, etcitype:enhancementneeds-minor-releaseThis PR cannot be merged until the next minor releaseprio:low

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions