@@ -186,7 +186,7 @@ public struct SmallProjectionPath : Hashable, CustomStringConvertible, NoReflect
186186
187187 /// Pops \p numBits from the path.
188188 private func pop( numBits: Int ) -> SmallProjectionPath {
189- return Self ( bytes: bytes & >> numBits)
189+ return Self ( bytes: bytes >> numBits)
190190 }
191191
192192 /// Pops and returns the first path component included the resulting path
@@ -210,7 +210,7 @@ public struct SmallProjectionPath : Hashable, CustomStringConvertible, NoReflect
210210 // Ignore zero indices
211211 return self
212212 }
213- if k == . indexedElement {
213+ if k == . indexedElement && index &+ i >= 0 {
214214 // "Merge" two constant successive indexed elements
215215 return pop ( numBits: numBits) . push ( . indexedElement, index: index + i)
216216 }
@@ -663,7 +663,8 @@ extension SmallProjectionPath {
663663 overlapping ( )
664664 predicates ( )
665665 path2path ( )
666-
666+ indexedElements ( )
667+
667668 func basicPushPop( ) {
668669 let p1 = SmallProjectionPath ( . structField, index: 3 )
669670 . push ( . classField, index: 12345678 )
@@ -925,5 +926,23 @@ extension SmallProjectionPath {
925926 assert ( result == nil )
926927 }
927928 }
929+
930+ func indexedElements( ) {
931+ let p1 = SmallProjectionPath ( . indexedElement, index: 1 )
932+ let ( k1, i1, s1) = p1. pop ( )
933+ assert ( k1 == . indexedElement && i1 == 1 && s1. isEmpty)
934+
935+ let p2 = SmallProjectionPath ( . indexedElement, index: - 1 )
936+ let ( k2, _, s2) = p2. pop ( )
937+ assert ( k2 == . anything && s2. isEmpty)
938+
939+ let p3 = SmallProjectionPath ( . indexedElement, index: 0xfffffffffffff )
940+ let ( k3, i3, s3) = p3. pop ( )
941+ assert ( k3 == . indexedElement && i3 == 0xfffffffffffff && s3. isEmpty)
942+
943+ let p4 = p3. push ( . indexedElement, index: Int . max)
944+ let ( k4, _, s4) = p4. pop ( )
945+ assert ( k4 == . anyIndexedElement && s4. isEmpty)
946+ }
928947 }
929948}
0 commit comments