Skip to content
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

Named unapply selectors accept random names #22192

Open
KacperFKorban opened this issue Dec 11, 2024 · 1 comment
Open

Named unapply selectors accept random names #22192

KacperFKorban opened this issue Dec 11, 2024 · 1 comment
Assignees
Labels
area:named-tuples Issues tied to the named tuples feature. itype:bug

Comments

@KacperFKorban
Copy link
Member

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

@KacperFKorban KacperFKorban added itype:bug area:named-tuples Issues tied to the named tuples feature. labels Dec 11, 2024
@KacperFKorban
Copy link
Member Author

The problem is most likely that the tryEither here swallows the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:named-tuples Issues tied to the named tuples feature. itype:bug
Projects
None yet
Development

No branches or pull requests

1 participant