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

[YAMLTraits] Fix std::optional input on empty documents #68947

Merged

Conversation

akirchhoff-modular
Copy link
Contributor

When the input document is non-empty, mapOptional works as expected, setting std::optional to std::nullopt when the field is not present. When the input document is empty, we hit a special case inside of Input::preflightKey that results in UseDefault = false, which results in the std::optional erroneously being set to a non-nullopt value. preflightKey is changed to set UseDefault = true in this case to make the behavior consistent between empty and non-empty documents.

When the input document is non-empty, `mapOptional` works as expected,
setting `std::optional` to `std::nullopt` when the field is not present.
When the input document is empty, we hit a special case inside of
`Input::preflightKey` that results in `UseDefault = false`, which
results in the `std::optional` erroneously being set to a non-nullopt
value.  `preflightKey` is changed to set `UseDefault = true` in this
case to make the behavior consistent between empty and non-empty
documents.
Copy link
Contributor

@slinder1 slinder1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this LGTM!

@JoeLoser JoeLoser merged commit 4bf10f3 into llvm:main Oct 16, 2023
@JoeLoser
Copy link
Member

@akirchhoff-modular - as discussed offline, I just went ahead and landed this for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants