Skip to content

Tuple.fromProduct doesn't handle Product0 #11792

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

Closed
sirthias opened this issue Mar 17, 2021 · 0 comments · Fixed by #11793
Closed

Tuple.fromProduct doesn't handle Product0 #11792

sirthias opened this issue Mar 17, 2021 · 0 comments · Fixed by #11793
Milestone

Comments

@sirthias
Copy link
Contributor

Compiler version

3.0.0-RC1

Minimized code

scala> case class Foo()
// defined case class Foo

scala> Tuple.fromProduct(Foo())
java.lang.AssertionError: assertion failed
  at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
  at scala.runtime.TupleXXL.<init>(TupleXXL.scala:4)
  at scala.runtime.TupleXXL$.fromIArray(TupleXXL.scala:45)
  at scala.runtime.Tuples$.fromProduct(Tuples.scala:174)
  at scala.Tuple$.fromProduct(Tuple.scala:229)
  ... 27 elided

Expectation

Tuple.fromProduct(Foo()) should return EmptyTuple.

On this note: Why is it called EmptyTuple instead of Tuple0?
We have Function0, Product0 (at least I think we do) and EmptyTuple, which appears to be inconsistent naming-wise.

Solution

The match in scala.runtime.Tuples.fromProduct simply needs another branch, similar to the one already present in fromArray.

sirthias added a commit to sirthias/dotty that referenced this issue Mar 17, 2021
sirthias added a commit to sirthias/dotty that referenced this issue Mar 17, 2021
liufengyun added a commit that referenced this issue Mar 22, 2021
Fix #11792 (Tuple.fromProduct doesn't handle Product0)
michelou pushed a commit to michelou/scala3 that referenced this issue Mar 22, 2021
michelou pushed a commit to michelou/scala3 that referenced this issue Mar 22, 2021
michelou pushed a commit to michelou/scala3 that referenced this issue Apr 14, 2021
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 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.

2 participants