Skip to content

False positive unused parameter warning in 3.7 nightly on method with default parameters #22748

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
mrdziuban opened this issue Mar 7, 2025 · 2 comments · Fixed by #22749
Closed
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Milestone

Comments

@mrdziuban
Copy link

Compiler version

3.7.0-RC1-bin-20250306-73ba485-NIGHTLY

Minimized code

def test[I, A](in: I)(
  run: I => Either[Throwable, A],
  onErr: Throwable => Throwable = identity[Throwable]
): Either[Throwable, A] =
  run(in) match {
    case Left(t) => Left(onErr(t))
    case r @ Right(_) => r
  }

Output

-- [E198] Unused Symbol Warning: /Users/matt/scala3.7-nightly-unused/src/main/scala/example/Test.scala:1:15 ------------
1 |def test[I, A](in: I)(
  |               ^^
  |               unused explicit parameter

Expectation

in should not be reported unused since it's passed to run. If I remove the default param for onErr then it compiles without warning

@mrdziuban mrdziuban added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 7, 2025
@mrdziuban
Copy link
Author

Possibly related to (or a duplicate of) #22746

@som-snytt
Copy link
Contributor

Example is included in test for the other ticket.

sjrd added a commit that referenced this issue Mar 10, 2025
Fixes #22746 
Fixes #22748 

Default arg getters are defined with dependencies they don't use.
@WojciechMazur WojciechMazur added this to the 3.7.0 milestone Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants