Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
szymon-rd opened this issue Oct 2, 2023 · 0 comments · Fixed by #20308
Closed
Assignees
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug
Milestone

Comments

@szymon-rd
Copy link
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.

@szymon-rd szymon-rd added itype:bug area:linting Linting warnings enabled with -W or -Xlint labels Oct 2, 2023
@szymon-rd szymon-rd 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 Oct 2, 2023
@szymon-rd szymon-rd 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 Oct 2, 2023
@szymon-rd szymon-rd self-assigned this Oct 2, 2023
@Gedochao Gedochao assigned rochala and unassigned szymon-rd Apr 5, 2024
sjrd added a commit that referenced this issue May 1, 2024
Closes #18632

It seems like the test is passing, probably due to changes with -Werror.
@Kordyjan Kordyjan added this to the 3.5.0 milestone May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants