From d6aa6dc2bf8e9e91a9f6206463acb44bfdf1ad85 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Sun, 16 Nov 2025 09:31:38 +0100 Subject: [PATCH] Add reproducer for github issue 294 This did compile until c674e94c3d409b6ab0ee05429361e8b50fe30320. --- test/github_issues.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/github_issues.cpp b/test/github_issues.cpp index 1db8ea41..b037f501 100644 --- a/test/github_issues.cpp +++ b/test/github_issues.cpp @@ -512,6 +512,42 @@ void github_pr_290() BOOST_TEST(*result == "foo"); } +namespace github_issue_294_ { + namespace bp = boost::parser; + struct Foo {}; + constexpr bp::rule> foo_parser = "foo_parser"; + constexpr auto foo_parser_action = [](auto& ctx) { + std::shared_ptr& val = _val(ctx); + val = std::shared_ptr(new Foo{}); + }; + constexpr auto foo_parser_def = bp::eps[foo_parser_action]; + struct Bar { std::shared_ptr foo; }; + constexpr bp::rule> bar_parser = "bar_parser"; + constexpr auto bar_parser_action = [](auto& ctx) { + std::shared_ptr& val = _val(ctx); + val = std::shared_ptr(new Bar{}); + std::optional>& attr = _attr(ctx); + if (attr) { + val->foo = attr.value(); + } + }; + constexpr auto bar_parser_def = + (bp::lit("(") > -foo_parser > bp::lit(")"))[bar_parser_action]; + + BOOST_PARSER_DEFINE_RULES( + bar_parser, + foo_parser); + + +} +void github_issue_294() +{ + namespace bp = boost::parser; + using namespace github_issue_294_; + + bp::parse("()", bar_parser, bp::blank); +} + int main() { @@ -528,5 +564,6 @@ int main() github_issue_279(); github_issue_285(); github_pr_290(); + github_issue_294(); return boost::report_errors(); }