milessabin / shapeless

Generic programming for Scala

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RemoveAll for record gives results in wrong order in some cases

travisbrown opened this issue · comments

The ops.record.RemoveAll type class takes a removal argument that can either be labelled or unlabelled. If the original record contains a type that appears multiple times, and if this type also appears multiple times in an unlabelled removal argument, the results will be in the wrong order.

For example:

import shapeless._
import ops.record.RemoveAll, record.Record, syntax.singleton._

type R = Record.`'i -> Int, 's -> String, 'c -> Char, 'j -> Int`.T
val r: R = Symbol("i") ->> 10 :: Symbol("s") ->> "foo" :: Symbol("c") ->> 'x' :: Symbol("j") ->> 42 :: HNil

type A = Int :: Int :: HNil
val removeAll = RemoveAll[R, A]

And then:

scala> removeAll(r)
res0: removeAll.Out = (42 :: 10 :: HNil,foo :: x :: HNil)

This is a pretty old bug (that I was responsible for) that @abdheshkumar noticed last week.