Skip to content

Spurious unused patvar warning when used pattern is a type pattern in a for #12497

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
martijnhoekstra opened this issue Nov 15, 2021 · 4 comments
Labels

Comments

@martijnhoekstra
Copy link

reproduction steps

using Scala 2,

for {
  (_, _) <- Option(1 -> 2)
  (c: Int, _) = 3 -> 4
} {
  println(c)
}

under -Wunused:patvar

pattern var c in value $anonfun is never used: use a wildcard _ or suppress this warning with c@_

problem

c is used, but reported as unused

@dwijnand
Copy link
Member

In the desugaring there will be extra patterns which end up being unused. It's unfortunate. I'll let @som-snytt close as duplicate if this is documented somewhere already.

@dwijnand dwijnand added the lint label Nov 15, 2021
@martijnhoekstra martijnhoekstra changed the title Spurious unused patvar warning in superfluous Spurious unused patvar warning when used pattern is a type pattern in a for Nov 15, 2021
@SethTisue
Copy link
Member

#10287 ?

@som-snytt
Copy link

som-snytt commented Nov 16, 2021

Thanks @SethTisue I couldn't find it and then got distracted looking at old tickets.

Because sometimes on a cold autumn day, it's nice to settle down under a wool blanket and take out your collection of old tickets and sort them again, fondly recalling bygone days of frustration and puzzlement.

@dwijnand
Copy link
Member

Duplicate of #10287

@dwijnand dwijnand marked this as a duplicate of #10287 Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants