Skip to content

Adding -Werror to -Wnonunit-statement can cause givens not to be available anymore #18632

Closed
@szymon-rd

Description

@szymon-rd

Compiler version

3.3.1

Minimized code

//> using scala "3.3.1"
//> using options -Wnonunit-statement -Werror

class Context

object Foo {
  def run(program: Context ?=> String): Unit = ???
}

def bar(using Context): String = ???

@main def run = Foo.run:
  bar
  bar

Output - givens not available, no linting warn:

Compiling project (Scala 3.3.1, JVM)
[error] ./Foo.scala:13:6
[error] No given instance of type Context was found for parameter x$1 of method bar
[error]   bar
[error]      ^
[error] ./Foo.scala:14:6
[error] No given instance of type Context was found for parameter x$1 of method bar
[error]   bar
[error]      ^
Error compiling project (Scala 3.3.1, JVM)

Removing -Werror causes the givens to be available again, and unused warn is reported:

Compiling project (Scala 3.3.1, JVM)
[warn] ./Foo.scala:13:3
[warn] unused value of type String
[warn]   bar
[warn]   ^^^
Compiled project (Scala 3.3.1, JVM)

Reported in VirtusLab/besom#200

Expectation

Givens should be available, and linting error should be reported.

Metadata

Metadata

Assignees

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