Using Boost.Hana causes hard compiler errors in some attribute propagation paths

Open
#336 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp
Domain
backend

Research direction

Start in parser.hpp at the semantic action dispatch and attribute assembling paths around the two locations shown in the issue. Check how tuple operations follow BOOST_PARSER_USE_HANA_TUPLE elsewhere, then build the Mutable Symbol Tables tutorial example with Hana tuples. Done means the example builds and the existing std::tuple path still works.

Written by the indexing model from the issue text.

Description

It seems semantic action dispatch and attribute "assembling" is hardcoded to use std::tuple ignoring BOOST_PARSER_USE_HANA_TUPLE flag.

Tutorial's example for Mutable Symbol Tables fails during build if uses Hana tuples (as current version of tutorial does).

Here is brief patch, which most likely don't follow library conventions but should make this issue visible:

diff --git a/parser.hpp b/parser.hpp
index 6a32dfb..18e8f51 100644
--- a/parser.hpp
+++ b/parser.hpp
@@ -3548,9 +3548,17 @@ namespace boost { namespace parser {
             };
             detail::skip(first, last, skip, flags);

+#if defined(BOOST_PARSER_USE_HANA_TUPLE)
+            boost::hana::unpack(parsers_, [&try_parser](auto&&... args) {
+#else
             std::apply([&try_parser](auto&&... args) {
+#endif
                 ((try_parser(args)), ...);
+#if defined(BOOST_PARSER_USE_HANA_TUPLE)
+            });
+#else
             }, parsers_);
+#endif

             if (!done)
                 success = false;
@@ -4608,9 +4616,18 @@ namespace boost { namespace parser {

             auto const parsers_and_indices =
                 detail::hl::zip(parsers_, indices, merged, backtracking{});
+#if defined(BOOST_PARSER_USE_HANA_TUPLE)
+            boost::hana::unpack(
+                parsers_and_indices, [&use_parser](auto&&... args) {
+#else
             std::apply([&use_parser](auto&&... args) {
+#endif
                 ((use_parser(args)), ...);
+#if defined(BOOST_PARSER_USE_HANA_TUPLE)
+            });
+#else
             }, parsers_and_indices);
+#endif
         }

         template<bool AllowBacktracking, typename Parser>
Dominant language
C++
Stars
185
Forks
28
Avg merge
20h 44m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/parser

All issues in boostorg/parser

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.