diff --git a/include/boost/sml.hpp b/include/boost/sml.hpp index 12c8da6f..962b17a2 100644 --- a/include/boost/sml.hpp +++ b/include/boost/sml.hpp @@ -1013,7 +1013,7 @@ struct transitions_sub, T, Ts...> { if (sub_sm>::cget(&subs).is_terminated()) { return transitions::execute(event, sm, deps, subs, current_state); } else { - return sub_sm>::get(&subs).process_event(event, deps, subs); + return sub_sm>::get(&subs).process_internal_events(event, deps, subs); } return false; } @@ -1044,8 +1044,8 @@ struct transitions_sub> { return sub_sm>::get(&subs).process_event(event, deps, subs); } template - constexpr static bool execute(const anonymous &, SM &, TDeps &, TSubs &, typename SM::state_t &) { - return false; + constexpr static bool execute(const anonymous &, SM &, TDeps &deps, TSubs &subs, typename SM::state_t &) { + return sub_sm>::get(&subs).process_internal_events(anonymous{}, deps, subs); } }; } // namespace back diff --git a/test/ft/composite.cpp b/test/ft/composite.cpp index b3ab5a64..2059fbe3 100644 --- a/test/ft/composite.cpp +++ b/test/ft/composite.cpp @@ -937,14 +937,14 @@ test composite_sub_guards = [] { bool is_ok = false; sml::sm sm{c_, guard_counter, is_ok}; expect(std::vector{calls::a1_entry} == c_); - expect(guard_counter == 1); + expect(guard_counter <= 2); guard_counter = {}; sm.process_event(e2{}); - expect(guard_counter == 1); + expect(guard_counter <= 2); guard_counter = {}; is_ok = true; sm.process_event(e2{}); - expect(guard_counter == 1); + expect(guard_counter <= 2); expect(std::vector{calls::a1_entry, calls::a1_exit, calls::a2_entry} == c_); guard_counter = {}; sm.process_event(e1{}); @@ -1002,3 +1002,50 @@ test composite_with_string_names = [] { expect(sm.is(X)); }; #endif + +test nested_composite_anonymous = [] { + using namespace boost::sml; + + struct Leaf { + struct INITIAL {}; + struct FINAL {}; + + auto operator()() const { + using namespace boost::sml; + + /* clang-format off */ + return make_transition_table( + *state = state, + state = X + ); + /* clang-format on */ + } + }; + + struct Top { + // states + struct INITIAL {}; + struct SUCCESS {}; + + // events + struct WIN {}; + struct LOSE {}; + + auto operator()() const { + using namespace boost::sml; + + /* clang-format off */ + return make_transition_table( + *state = state, + state + event = X, + state + event = state + ); + /* clang-format on */ + } + }; + + sm sm; + + expect(sm.is(state)); + expect(sm.is)>(X)); +};