Skip to content

Optional is set even though optional_parser fails #279

@andreasbuhr

Description

@andreasbuhr

In the following code, parsing a do-statement with a condition (heavily simplified), the std::optional representing the condition should not be set. However, it is. This is a bug in boost.parser.

void reproducer()
{
    namespace bp = boost::parser;

    constexpr auto condition_clause =
        bp::lit(U"while") > bp::lit(U"someexpression") >> bp::attr(true) ;

    constexpr auto do_statement =
        bp::lexeme[bp::lit(U"do") >> &bp::ws] > -condition_clause > bp::eol;


    {
        auto result = bp::parse(
            U"do\n"
            , do_statement, bp::blank, bp::trace::off);
        BOOST_TEST(result);
        std::optional<bool>& condition = result.value();
        BOOST_TEST(!condition.has_value());
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions