Re: Unexpected productIterator order

Jason Zaugg <[email protected]>
Newsgroups gmane.comp.lang.scala
Message-ID <CAG3_yeWDYgpzCQvkEp7Aki7gC0+3aTcaKFNP1k3c6Ntg93VHnA@mail.gmail.com>
This appears to have the same root cause as SI-8831
<https://issues.scala-lang.org/browse/SI-8831>. I have added your example
to that bug, I'll include it as a test case when we fix this.

For now the workaround is to avoid using backticked case class param names
that start with the name of another parameter.

-jason

On Thu, Mar 19, 2015 at 10:44 AM, Simon Schäfer <[email protected]> wrote:

>
> On 03/19/2015 06:15 PM, Simon Adameit wrote:
>
>  Hello,
>
>  we noticed some strange behaviour of productIterator in Scala 2.11.5:
>
>  case class Data(a: String, b: String, `a-some`: String)
> val m = Data("1", "2", "3")
> assert(m.productIterator.mkString(", ") == "1, 2, 3")
>
>  Result: "1, [3, 2]" did not equal "1, [2, 3]"
>
>  "a-some" can be any mangled symbol with an "a" prefix.
>
>  Is the order of productIterator on case classes guaranteed to be in
> parameter order? If so, this seems to be a bug. Can anyone reproduce it?
>
> Product.productElement (
> http://scala-lang.org/api/current/index.html#scala.Product@productElement%28n:Int%29:Any)
> says:
>
> The nth element of this product, 0-based. In other words, for a product
> A(x1, ..., xk), returns x(n+1) where 0 < n < k.
>
> Therefore, it is a bug in productElement. However, productIterator doesn't
> specify ordering...
>
>
>  Regards,
> Simon Adameit
>  --
> You received this message because you are subscribed to the Google Groups
> "scala-language" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "scala-language" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.