Skip to content

Incorrect dead pure code warning for inline parameters #9751

@liufengyun

Description

@liufengyun

Minimized code

object Test {
  extension (x: Int)
    inline def times(inline op: Unit): Unit = {
      var count = 0
      while count < x do
        op
        count += 1
    }

  10.times { println("hello") }
}

Output

-- [E129] Potential Issue Warning: examples/times.scala:7:8 --------------------
7 |        op
  |        ^^
  |A pure expression does nothing in statement position; you may be omitting necessary parentheses

Expectation

The compiler should not generate the warning.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions