Skip to content

For-comp with no yield should use .foreach #43

Open
@japgolly

Description

@japgolly

reproduction steps

Desugar the following:

for {x <- List(1); y = 1} ()

problem

It effectively desugars to:

List(1).map { x => val y = 1; (x, y) }.foreach { case (x, y) => () }

expectation

Because there's no yield, I expect all .flatMap and .map calls to be .foreach instead. It should desugar to:

List(1).foreach { x => val y = 1; () }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions