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

Crash on sequence-match if Product is inherited and intermediary _X is not defined #19220

Closed
SrTobi opened this issue Dec 7, 2023 · 3 comments · Fixed by #19277
Closed

Crash on sequence-match if Product is inherited and intermediary _X is not defined #19220

SrTobi opened this issue Dec 7, 2023 · 3 comments · Fixed by #19277

Comments

@SrTobi
Copy link
Contributor

SrTobi commented Dec 7, 2023

Compiler version

3.3.1

Minimized code

object Test:
  class Custom extends scala.Product1[String]:
    def length: Int = ???
    def apply(i: Int): Boolean = ???
    def drop(n: Int): scala.Seq[Boolean] = ???
    def toSeq: scala.Seq[Boolean] = ???

    def canEqual(that: Any): Boolean = ???

    val _1: String = ???
    val _3: Seq[String] = ???

  class Unapplied:
    def isEmpty: Boolean = ???
    def get: Custom = ???

  object A:
    def unapplySeq(i: Int): Unapplied = ???

  val A(a, rest*) = 1

Output (click arrow to expand)

scala: undefined: x9.<none> # -1: TermRef(TermRef(NoPrefix,val x9),<none>) at preRecheck
@SrTobi SrTobi added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 7, 2023
@SrTobi SrTobi changed the title Crash when sequence and product-sequence match are possible and intermediary _X is not defined Crash on sequencet-match if Product is inherited and intermediary _X is not defined Dec 7, 2023
@mbovel mbovel added area:pattern-matching and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 11, 2023
@odersky odersky removed their assignment Dec 12, 2023
@odersky odersky added the backlog No work planned on this by the core team for the time being. label Dec 12, 2023
@odersky
Copy link
Contributor

odersky commented Dec 12, 2023

This is carefully engineered to confuse the compiler on multiple levels. Fixing it will be quite a challenge. Is there a real world example where this happened? Is there a workaround?

@SrTobi
Copy link
Contributor Author

SrTobi commented Dec 12, 2023

I came up with these test cases by looking at the specification and coming up with edge cases to test our own implementation of the unapply/unapplySeq match semantics in the intellij-scala plugin. So no, these are not real world examples, just what the specification allows.

@odersky
Copy link
Contributor

odersky commented Dec 12, 2023

Thanks for the info. We need to have a closer look at this and compare it with the spec.

@odersky odersky added area:spec and removed backlog No work planned on this by the core team for the time being. labels Dec 12, 2023
@dwijnand dwijnand changed the title Crash on sequencet-match if Product is inherited and intermediary _X is not defined Crash on sequence-match if Product is inherited and intermediary _X is not defined Dec 15, 2023
@dwijnand dwijnand linked a pull request Dec 15, 2023 that will close this issue
@dwijnand dwijnand self-assigned this Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants