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

Incorrect "Wrong number of argument patterns" error for Option extractor using Tuple.Map #22923

Open
eejbyfeldt opened this issue Apr 7, 2025 · 0 comments

Comments

@eejbyfeldt
Copy link

Compiler version

3.6.4

Minimized code

object Test {
  object E1 {
    def unapply(x: Int): Some[Tuple.Map[(Int, Int), Option]] = ???
  }

  val s: Int = ???
  s match {
    case E1(x, y) => x
  }
}

Output

$ scalac unapply_matchtype.scala 
-- [E107] Syntax Error: unapply_matchtype.scala:10:11 ----------------------------------------
10 |    case E1(x, y) => x
   |         ^^^^^^^^
   | Wrong number of argument patterns for Test.E1; expected: ((Option[Int], Option[Int]))
   |
   | longer explanation available when compiling with `-explain`
1 error found

Expectation

Code should compile without warnings or errors.

Dropping the Option in the return type makes the code work. So the following code compiles

object Test {
  object E1 {
    def unapply(x: Int): Tuple.Map[(Int, Int), Option] = ???
  }

  val s: Int = ???
  s match {
    case E1(x, y) => x
  }
}

But can not be used a general fix at that will run into #22355 in generic code.

@eejbyfeldt eejbyfeldt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 7, 2025
@eejbyfeldt eejbyfeldt changed the title Wrong number of argument Incorrect "Wrong number of argument patterns" error for Option extractor using Tuple.Map Apr 7, 2025
@Gedochao Gedochao added area:tuples and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants