mokus0 / bitvec

Bit arrays for Haskell
Other
8 stars 0 forks source link

Data.Vector.Unboxed.Mutable.grow is broken #4

Open roconnor opened 8 years ago

roconnor commented 8 years ago
> runST $ do { v0 <- Data.Vector.Unboxed.Mutable.replicate 1 (fromBool True)
             ; v1 <- Data.Vector.Unboxed.Mutable.grow v0 1
             ; fv0 <- freeze v0
             ; fv1 <- freeze v1
             ; return (fv0, fv1)
             }
([1],[0,0])

expected result

([1],[1,0])

This suggests there is an error in BasicUnsafeCopy or BasicUnsafeSlice as BasicUnsafeGrow has a default implementation in terms of them.

mokus0 commented 8 years ago

Unfortunately I don't think I'll have time to look into this this weekend. A couple notes for future reference:

I initially wasn't able to reproduce this issue, but after adding a quickcheck test for it, travis-ci exhibited the issue. I noticed the travis build was using a newer version of vector (0.11.0.0, I had 0.10.9.1). Upon upgrading to 0.11.0.0, the test broke locally as well.

It's been quite a while since I looked at this code, and looking back over it I am suspecting the issue probably lies in basicUnsafeCopy. There's a lot of room for improvement there, so I may just rewrite it when I have some time.