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

ensure that getstring resets the position of IO #123

Merged
merged 1 commit into from
Jun 15, 2022

Conversation

KristofferC
Copy link
Contributor

Before this PR, this happened:

julia> source = IOBuffer("\"str1\" \"str2\"");

julia> opt = Parsers.Options(; quoted=true);

julia> res = Parsers.xparse(String, source, 1, 0, opt);
Parsers.Result{PosLen}(5, 7, PosLen(0x0000000000200004))

julia> @test Parsers.getstring(source, res.val, opt.e) == "str1"
Test Passed

julia> res = Parsers.xparse(String, source, 1 + res.tlen, 0, opt)
Parsers.Result{PosLen}(5, 3, PosLen(0x0000000000900001))

julia> @test Parsers.getstring(source, res.val, opt.e) == "str2"
Test Failed at REPL[7]:1
  Expression: Parsers.getstring(source, res.val, opt.e) == "str2"
   Evaluated: "s" == "str2"
ERROR: There was an error during testing

Copy link
Member

@quinnj quinnj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The source as IO codepath may have occasional bugs like this as it's not as widely used as the AbstractVector{UInt8} paths.

@quinnj quinnj merged commit fbc1dd8 into JuliaData:main Jun 15, 2022
@KristofferC KristofferC deleted the kc/reset_io branch June 15, 2022 17:17
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

Successfully merging this pull request may close these issues.

2 participants