Skip to content

Fix raw value constructor vs de parsing incompatibility#487

Merged
juntyr merged 6 commits into
ron-rs:masterfrom
juntyr:consistent-raw-value
Aug 24, 2023
Merged

Fix raw value constructor vs de parsing incompatibility#487
juntyr merged 6 commits into
ron-rs:masterfrom
juntyr:consistent-raw-value

Conversation

@juntyr

@juntyr juntyr commented Aug 23, 2023

Copy link
Copy Markdown
Member
  • I've included my change in CHANGELOG.md
  • Add test case for fuzzer-found hardcoded identifier bug

@juntyr

juntyr commented Aug 23, 2023

Copy link
Copy Markdown
Member Author

@torkleyy This is quite an annoying bug and I am not sure if this is the right way forward to fix it. The problem is that RawValue will have to be annoying in one of two ways:

a) RawValue::from_ron("/*hi*/ 42 /*bye*/") works as expected (i.e. any valid ron, except for attributes, can be used in the constructor and will be pasted literally into the output). However, deserialising only roundtrips if no pretty serialising is used since any pretty whitespace or comments will be eaten up by the raw value upon the next deserialising. I'm going with this option right now.

b) RawValue::from_ron("/*hi*/ ( /*yay*/ 42 /*lol*/ ) /*bye*/") only keeps ( /*yay*/ 42 /*lol*/ ) (so all whitespace before and after the first non-whitespace is lost), but roundtripping works since additional pretty whitespace is dropped.

Which one would you prefer?

@codecov-commenter

codecov-commenter commented Aug 23, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.04% 🎉

Comparison is base (a293382) 95.27% compared to head (6abc432) 95.32%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #487      +/-   ##
==========================================
+ Coverage   95.27%   95.32%   +0.04%     
==========================================
  Files          74       74              
  Lines        8852     8936      +84     
==========================================
+ Hits         8434     8518      +84     
  Misses        418      418              
Files Changed Coverage Δ
src/de/mod.rs 96.57% <100.00%> (+0.01%) ⬆️
src/de/tests.rs 100.00% <100.00%> (ø)
src/parse.rs 96.62% <100.00%> (+0.01%) ⬆️
src/ser/mod.rs 96.61% <100.00%> (+0.01%) ⬆️
src/value/raw.rs 100.00% <100.00%> (ø)
tests/407_raw_value.rs 100.00% <100.00%> (ø)
tests/481_number_underscores_suffixes.rs 99.81% <100.00%> (+0.01%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@torkleyy

Copy link
Copy Markdown
Member

Approach a seems like the better one, yeah.

@juntyr juntyr merged commit 05b46c8 into ron-rs:master Aug 24, 2023
@juntyr juntyr deleted the consistent-raw-value branch August 24, 2023 16:56
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.

3 participants