-
Notifications
You must be signed in to change notification settings - Fork 10
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
putWord8 has a problem (or it's just me) #4
Comments
I'm happy you're showing interest in the project, and we can work together to make the patches good. But please consider doing pull requests for new code. It makes it easy to follow several related commits for the same feature/issue, and makes it super simple for me to merge the code. Also, if we decide to not pursue a certain idea, it's easy to just ditch the branch. For this particular commit, since you're fixing a bug, it'd be awesome to see a use case where the code misbehaves without your fix. |
Example: import Control.Applicative
import Control.Monad
import Data.Bits
import Data.Word
import Data.Binary.Bits
import Data.Binary.Bits.Get
import Data.Binary.Bits.Put
import qualified Data.Binary.Put as Binary
import qualified Data.Binary.Get as Binary
test :: Word8 -> Bool
test w8 = (Binary.runGet (Binary.getWord8) $
Binary.runPut (runBitPut (putBool False >> putWord8 7 w8))) == clearBit w8 7 This is how it is supposed to work, right? So putBool gives us offset 1, and putWord8 7, that's n = 7, so:
gives (0x0 | w << 0) == w Gotta run, I'll reply to other comments later. |
Yes, you are right. |
Seems there are two similar bugs in In addition, most likely |
My patches are getting dumber every day. I hope this one is not over the limit yet.
polachok@1f742ee
No tests. No fixes for the same problem in other functions. Why? Because it looks like an obvious problem and if it went unnoticed for long time, there's probably nothing wrong and I'm misunderstanding something.
The text was updated successfully, but these errors were encountered: