Skip to content

Consider checking -Wnonunit-statement after macro expansion #22546

Open
@kyri-petrou

Description

@kyri-petrou

Compiler version

3.3.5, 3.6.3

Minimized code

//> using scala 3.6.3
//> using options -Wnonunit-statement, -Xfatal-warnings

object Main {
  def foo(): String = "foo"

  def code = scala.compiletime.codeOf {
    foo()
    foo()
  }
}

Output

Compiler warning / error:

unused value of type String
  foo()

Expectation

This code should not emit any warnings as the foo() statement is not discarded. This behaviour (checking for non-unit statements) is causing an issue for zio-test users that have this warning enabled; see zio/zio#9233 and zio/zio#9552.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions