Inconsistencies in std::optional<std::optional<FOO>> collapsing
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with the nested-optional parser expression in the issue and inspect how optional collapsing is currently documented and tested. Reproduce the "hallo there" case, determine whether the resulting optional should reflect the outer or inner parser, and document and test the chosen behavior.
Written by the indexing model from the issue text.
Description
Hi,
right now I have little time, so I write this short report. I hope to find time in the future to extend it with a reproducer and maybe a proposed fix.
There seem to be some inconsistencies, or at least a lack of documentation, around the collapsing of nested optionals.
Given for example this parser:
constexpr auto my_parser = bp::lit(U"hallo") >> -(bp::lit(u"there") >> -(bp::lit(U"Markus") >> bp::attr(true)));
Without any collapsing, the argument type would be std::optional<std::optional<bool>>. But because of the collapsing, it is a bp::optional<bool>. But now I am missing the documentation whether the state of that optional (set or not set) reflects the success of the outer optional parser or the inner optional parser.
Parsing the string "hallo there", it seems I get an optional which is set (set by the outer optional parser). But its content is default-constructed, because the inner optional parser failed and produced an std::nullopt;
My feeling is that it would be more consistent if the state of the resulting std::optional reflected the success of the inner optional parser. Either way, the behavior should be documented and tested.
- Dominant language
- C++
- Stars
- 182
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/parser
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
-
Difficulty 1/5 Under an hour Newbie friendliness 20/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
google/libultrahdr#485 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
godotengine/godot#123776 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 60/100
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
ros2/common_interfaces#344 ·