-
Notifications
You must be signed in to change notification settings - Fork 123
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
Round-trip failure: untagged enum containing Vec variant is improperly deserialized #357
Comments
I'll take a look now |
Ok, I think I can at least explain what's happening here. |
#253 might be related, I'll check if it would fix the issue |
With #253 the test case would pass, but: 1. Unit variants now deserialize to
|
Maybe at least part of |
Ok, I played around with it a bit more to get a feel of what a rough implementation could look like. It's essentially #253 but with (a) a fix that makes unnamed struct-likes work again (though this fix requires a lot more though to ensure it actually works in all edge cases) and (b) special handling in the |
You can have a look here master...MomoLangenstein:253-untagged-enums to see roughly what would be changed. |
I guess my summary is that
|
@MomoLangenstein has there been any further development on this issue? |
@NiklasEi I haven't done any more work on this since. If there is interest, I could definitely have another look and see if I could resolve some of the issues I came across during the initial attempt. However, this method seems to require |
Add a test to confirm that #357 is fixed
Thank you @obi1kenobi for providing a very good test case - I just realised that #451 fixed the issue and have added a test to ensure it remains working. |
My pleasure, thanks for the fix! 🙌 |
Consider the following types:
Let's try serializing a
MyValue::Enum
value like the following:MyValue::Enum(Enum::First("foo".to_string()))
. Its RON-serialized value isFirst("foo")
.That
First("foo")
value unfortunately deserializes toMyValue::List([MyValue::String("foo")])
instead of our original enum-based value. This is surprising to me, because the deserialization code decides to ignore theFirst
prefix entirely, and skip forward until the(
then deserialize a list with it. It's especially surprising because theMyValue::Enum
variant is before theMyValue::List
variant, and yet we still get aMyValue::List
back instead ofMyValue::Enum
.Here's a complete repro:
This fails with:
Thanks to everyone that contributes to building and maintaining this awesome library! Any advice on avoiding this issue would be much appreciated.
The text was updated successfully, but these errors were encountered: