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

Flow-style mapping values cause incorrect parse results #282

Closed
1 of 2 tasks
stephenwhittle opened this issue Mar 17, 2024 · 3 comments · Fixed by #283
Closed
1 of 2 tasks

Flow-style mapping values cause incorrect parse results #282

stephenwhittle opened this issue Mar 17, 2024 · 3 comments · Fixed by #283
Labels
bug Something isn't working

Comments

@stephenwhittle
Copy link
Contributor

Description

Flow-style mappings as values of an outer mapping cause subsequent entries in the outer mapping to be placed in the wrong location in the parsed tree.

Reproduction steps

The following minimal YAML file demonstrates the issue:

"DIEP0":
  DIEPCTL[0]: { name: CTL }
  description: Device IN endpoint 0

Expected vs. actual results

When using fkyaml::node::deserialize on the above fragment, the description element is placed at the top of the parsed tree as a sibling of DIEP0, rather than as a child of it (and sibling to the DIEPTCL[0] node).

Removing the call to m_node_stack.pop_back() at deserializer.hpp:283 appears to avoid the incorrect traversal by deferring to the traversal code at deserializer.hpp:369-375 in my testing, but I am uncertain if that is the appropriate, or sole fix, required.

Minimal code example

No response

Error messages

No response

Compiler and operating system

VS 2022 (both clang-cl and msvc compilers), Win 10

Library version

8bdce5e

Validation

@fktn-k
Copy link
Owner

fktn-k commented Mar 17, 2024

@stephenwhittle
Thanks for sharing the issue as well as your suggestion to fix it.
I'm not sure that the deferring doesn't break the history of indentations.

Removing the call to m_node_stack.pop_back() at deserializer.hpp:283 appears to avoid the incorrect traversal by deferring to the traversal code at deserializer.hpp:369-375 in my testing

Some additional changes related to this untouched topic (#175), may be required.

Do you have time to check whether or not your suggestion will do by running the unit tests?
If not, I can deal with it after #281 is solved which I guess won't affect this issue.

@stephenwhittle
Copy link
Contributor Author

I can confirm that the unit tests pass successfully on both MSVC and clang-cl with the suggested change, but happy for you to consider alternative solutions if you think they may be more robust for scenarios not currently covered by the test suite.

@fktn-k fktn-k added the bug Something isn't working label Mar 17, 2024
@fktn-k
Copy link
Owner

fktn-k commented Mar 17, 2024

@stephenwhittle
In my opinion, it's suffice to say that the change has fixed the issue, at least for now.
If you can afford to add that test case, could you please create a PR so I can incorporate it into the project as your modification?

fktn-k added a commit that referenced this issue Mar 17, 2024
#282 Don't traverse up to the parent node immediately after parsing a flow-mapping value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants