-
Notifications
You must be signed in to change notification settings - Fork 217
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
Deserialization fails if set_default is passed an unsigned integer #352
Comments
I feel like more and more issues come from the fact that we're deserializing internally and store things in our own data structure. Thanks for reporting this! 👍 I guess the fix looks alrightish, feel free to open a PR for this and we go from there! |
kesyog
added a commit
to kesyog/config-rs
that referenced
this issue
Jun 28, 2022
* Attempt to convert between integer types using `TryInto`-based conversions rather than blanket failing for some source and destination types. * Use `into_uint` instead of `into_int` in `Value` Deserialize implementations for unsigned integer types. Previously, we were converting from signed types to unsigned types using `as`, which can lead to surprise integer values conversions (rust-cli#93). Fixes rust-cli#352 and rust-cli#93
kesyog
added a commit
to kesyog/config-rs
that referenced
this issue
Jun 29, 2022
* Attempt to convert between integer types using `TryInto`-based conversions rather than blanket failing for some source and destination types. * Use `into_uint` instead of `into_int` in `Value` Deserialize implementations for unsigned integer types. Previously, we were converting from signed types to unsigned types using `as`, which can lead to surprise integer values conversions (rust-cli#93). Fixes rust-cli#352 and rust-cli#93
matthiasbeyer
pushed a commit
to matthiasbeyer/config-rs
that referenced
this issue
Aug 2, 2022
* Attempt to convert between integer types using `TryInto`-based conversions rather than blanket failing for some source and destination types. * Use `into_uint` instead of `into_int` in `Value` Deserialize implementations for unsigned integer types. Previously, we were converting from signed types to unsigned types using `as`, which can lead to surprise integer values conversions (rust-cli#93). Fixes rust-cli#352 and rust-cli#93 (cherry picked from commit 7db2e8b)
matthiasbeyer
pushed a commit
that referenced
this issue
Aug 2, 2022
* Attempt to convert between integer types using `TryInto`-based conversions rather than blanket failing for some source and destination types. * Use `into_uint` instead of `into_int` in `Value` Deserialize implementations for unsigned integer types. Previously, we were converting from signed types to unsigned types using `as`, which can lead to surprise integer values conversions (#93). Fixes #352 and #93 (cherry picked from commit 7db2e8b) Signed-off-by: Matthias Beyer <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Small motivating example that demonstrates the issue:
Output:
While looking into potentially fixing it, I noticed that
Value::into_uint
is defined but never used. Modifying thedeserialize_u32
method to useinto_uint
instead ofinto_int
fixes this issue, but breaks some existing tests. I'm guessing that's because of the next observation:Value::into_int
andValue::into_uint
both seem overly strict. For example, callingValue::into_uint()
when the kind is aValueKind::I64
always fails. Shouldn't we try a conversion using theTryInto
trait and only fail if the conversion fails?Draft PR showing what I'm envisioning: https://github.com/mehcode/config-rs/compare/master...kesyog:config-rs:kyogeswaran/deserialize-uints?expand=1
This looks potentially related to #93.
The text was updated successfully, but these errors were encountered: