Skip to content

[2.13.15] False negatives for unused pattern vars #13035

Closed as not planned
Closed as not planned
@bjaglin

Description

@bjaglin

It seems that 2.13.15 no longer reports unused pattern vars when they have the same name as the attributes.

Reproduction steps

//> using scala 2.13.15
//> using options -Wunused

case class CC(field1: Int, field2: Int)

object CC {
  CC(42, 42) match {
    case CC(field1, field2) => 1
  }
}

Problem

Actual

No warning

$ scala-cli compile PatternVars.scala 
$

Expected

Warnings like in 2.13.14

$ scala-cli compile -S 2.13.14 PatternVars.scala 
[warn] ./PatternVars.scala:8:21
[warn] pattern var field2 in value <local CC> is never used: use a wildcard `_` or suppress this warning with `field2@_`
[warn]     case CC(field1, field2) => 1
[warn]                     ^^^^^^
[warn] ./PatternVars.scala:8:13
[warn] pattern var field1 in value <local CC> is never used: use a wildcard `_` or suppress this warning with `field1@_`
[warn]     case CC(field1, field2) => 1
[warn]             ^^^^^^
$

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions