Skip to content

Named unapply selectors accept random names #22192

Closed
@KacperFKorban

Description

@KacperFKorban

Compiler version

91063dd

Minimized code

//> using scala 3.nightly

import scala.language.experimental.namedTuples

case class City(name: String, population: Int)

def getCityInfo(city: City) =
  city match
    case City(iam = n, confused = p) => s"[City] $n has a population of $p !!!!!!!!!!"

@main
def main =
  val city = City(name = "New York", population = 8_000_000)
  println(getCityInfo(city))

Output

[City] New York has a population of 8000000 !!!!!!!!!!

Expectation

Compilation error, that iam and confused aren't fields of the class City

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions