Skip to content
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

lookAhead and bytesRead #93

Open
td202 opened this issue Aug 4, 2020 · 2 comments
Open

lookAhead and bytesRead #93

td202 opened this issue Aug 4, 2020 · 2 comments

Comments

@td202
Copy link

td202 commented Aug 4, 2020

While lookAhead does not consume the input, it does update the bytesRead.

test = do
    x <- bytesRead
    _ <- lookAhead getInt64be
    y <- bytesRead
    return (x, y)

> runGet test (encode (2 :: Int)) -- result: Right (0, 8)

I suspect this is not the desired behaviour, and that the above example should return (0, 0), to reflect that no bytes of the input have been consumed. If this is the desired behaviour, it should probably be documented.

@elliottt
Copy link
Contributor

elliottt commented Aug 4, 2020

This seems like a bug to me, good find!

@jmazon
Copy link

jmazon commented Sep 15, 2021

Seems to me it's all the less likely to be the desired behavior that the same code does return (0,0) when run against binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants