Skip to content

lexeme[alpha >> *alnum] gets resolved into wrong overload of parse_sequence that expects fusion sequence with mismatched number of elements #27

Description

@JhnW

Hi.
I'm using boost 1.88 (latest on conan). This looks to me like another occurrence of the same bug/issue or just a missdesign that is problematic for people that I've seen around many times.

template <typename Iterator>
void parse_test(Iterator first, Iterator last)
{
    auto f_printer = [](auto& ctx){ std::cout <<"A:"<< std::endl; };
    auto const identifier = x3::lexeme[x3::alpha >> *x3::alnum]; // problematic line
    auto const function_call_def =  identifier >> "(" >> x3::double_ >> ")";
    const auto paarser = function_call_def[f_printer];
    bool r = phrase_parse(
        first,
        last,
        paarser,
        x3::space
        );
    std::cout<<"R: "<<r<<std::endl;
}

This code causes an assertion:

        // If you got an error here, then you are trying to pass
        // a fusion sequence with the wrong number of elements
        // as that expected by the (sequence) parser.
        static_assert(
            actual_size >= expected_size
          , "Size of the passed attribute is less than expected."
        );

from home/x3/operator/detail/sequence.hpp:140:25

Problematic line is auto const identifier = x3::lexeme[x3::alpha >> *x3::alnum]; Removind x3::lexeme and use const auto identifier = x3::alpha >> *x3::alnum; make code passing.

Also using BOOST_SPIRIT_DEFINE helps but i didn't see why I need to use this idiomatic flow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    need more infoRequires additional info from the user / maintainer needs more investigation

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions