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

Bug: Unexpected sign for large int64 decoding. #60

Open
travis-leith opened this issue Nov 5, 2024 · 2 comments
Open

Bug: Unexpected sign for large int64 decoding. #60

travis-leith opened this issue Nov 5, 2024 · 2 comments

Comments

@travis-leith
Copy link

open Thoth.Json.Net

type test_type = { i: int64 }

let extra = Extra.empty |> Extra.withInt64
let test_type_decoder = Decode.Auto.generateDecoder<test_type> (extra = extra)

let test_type_json1 = """{"i": 9223372036854775806}"""
let test_type_json2 = """{"i": 8223372036854775806}"""

let test_type1 = Decode.Auto.fromString<test_type> (test_type_json1, extra = extra)

let test_type2 = Decode.fromString test_type_decoder test_type_json2

printfn "test_type1: %A" test_type1
printfn "test_type2: %A" test_type2

For some reason the first value gets parsed as -ve. This seems to only happen for numbers close to the max value. Maybe some sort of overflow is happening.

@travis-leith
Copy link
Author

I found this bug by making sure that Decode.Auto.fromString works the same way as Decode.Auto.generateDecoder, if you are wondering why I use 2 different techniques here.

@MangelMaxime
Copy link
Contributor

Thank you for the report, I will investigate this issue while working on porting the Auto API to the new API.

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

2 participants