Skip to content

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

@szymon-rd

Description

@szymon-rd
Contributor

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.

Activity

changed the title [-]Adding -Werror to -Wnonunit-statement can cause givens to not be available anymre[/-] [+]Adding -Werror to -Wnonunit-statement can cause givens to not be available anymore[/+] on Oct 2, 2023
changed the title [-]Adding -Werror to -Wnonunit-statement can cause givens to not be available anymore[/-] [+]Adding -Werror to -Wnonunit-statement can cause givens not to be available anymore[/+] on Oct 2, 2023
self-assigned this
on Oct 2, 2023
added a commit that references this issue on May 1, 2024
added this to the 3.5.0 milestone on May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @szymon-rd@Kordyjan@rochala

    Issue actions

      Adding -Werror to -Wnonunit-statement can cause givens not to be available anymore · Issue #18632 · scala/scala3