asutton/clang

Tuple expansion bug

Opened this issue · 0 comments

There appears to be a bug in the instantiation of loop bodies involving the members of a class. From the literal value test:

$class literal_value {
  // Transform members
  constexpr {
    access_kind mode = default_access;
    for... (auto m : $literal_value.members()) { // NOTE: members
      if (mode == default_access) {
        if constexpr (m.is_member_variable()) {
          m.make_private();
        }
        
        if constexpr (m.is_member_function()) {
          m.make_public();
          m.make_constexpr();
        }
        
        if constexpr (m.is_access_specifier())
          mode = m.access();
      }
    }
  } // end metaprogram
}

When the loop is expanded, the conditions appear to be discarded in each block -- they are essentially empty if statements. However, if I change the range variable to e.g., member_functions, the body of the loop is correctly expanded.

It seems like the first expansion of the loop is determining the properties for all subsequent expansions. This could be an artifact of metaclass application.