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
uint64 range limited by int64 #781
Labels
bug
Issues describing a bug in go-toml.
Comments
Thank you for reporting this! |
jmank88
added a commit
to smartcontractkit/go-toml
that referenced
this issue
May 23, 2022
pelletier
added a commit
that referenced
this issue
Jun 1, 2022
As brought up on #782, there is an asymetry between numbers go-toml can encode and decode. Specifically, unsigned numbers larger than `math.Int64` could be encoded but not decoded. We considered two options: allow decoding of those numbers, or prevent those numbers to be decoded. Ultimately we decided to narrow the range of numbers to be encoded. The TOML specification only requires parsers to support at least the 64 bits integer range. Allowing larger numbers would create non-standard TOML documents, which may not be readable (at best) by other implementations. It is a safer default to generate documents valid by default. People who wish to deal with larger numbers can provide a custom type implementing `encoding.TextMarshaler`. Refs #781
pelletier
added a commit
that referenced
this issue
Jun 1, 2022
As brought up on #782, there is an asymetry between numbers go-toml can encode and decode. Specifically, unsigned numbers larger than `math.Int64` could be encoded but not decoded. We considered two options: allow decoding of those numbers, or prevent those numbers to be decoded. Ultimately we decided to narrow the range of numbers to be encoded. The TOML specification only requires parsers to support at least the 64 bits integer range. Allowing larger numbers would create non-standard TOML documents, which may not be readable (at best) by other implementations. It is a safer default to generate documents valid by default. People who wish to deal with larger numbers can provide a custom type implementing `encoding.TextMarshaler`. Refs #781
Merged 85bfc0e. It prevents the asymmetry problem you pointed out by preventing uint64 > maxInt64 to be encoded. Thank you again for reporting since and driving the discussion to improve the library! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Attempting to unmarshal a value a larger than
math.MaxInt64
results in avalue out of range
error fromstrconv.ParseInt
, even when the target field is auint64
.To Reproduce
https://go.dev/play/p/L_zgsE-vlAl
Expected behavior
I expected the full range of
uint64
values to be supported.Versions
The text was updated successfully, but these errors were encountered: