sml icon indicating copy to clipboard operation
sml copied to clipboard

Regression with v1.1.3: Anonymous transition no longer works in a nested state.

Open Rijom opened this issue 4 years ago • 0 comments

Expected Behavior

  //
  //        Parent
  //        +--------------------------------+
  //        |                                |
  //        |       +---+       +---+ evExit |
  //   *+--->  *+---> A +-------> B +----> X +----> X
  //        |       +---+       +---+        |
  //        |                                |
  //        +--------------------------------+
  //

I expect the state-machine to be in B after construction.

Actual Behavior

State-machine remains in A and does not take anonymous transition to B.

Steps to Reproduce the Problem

#include <boost/sml.hpp>
#include <catch2/catch.hpp>

namespace sml = boost::sml;

struct A{};
struct B{};

namespace sml = boost::sml;
TEST_CASE("SML. Anonymous transition in child") {
  //
  //        Parent
  //        +--------------------------------+
  //        |                                |
  //        |       +---+       +---+ evExit |
  //   *+--->  *+---> A +-------> B +----> X +----> X
  //        |       +---+       +---+        |
  //        |                                |
  //        +--------------------------------+
  //

  struct Parent {
    auto operator()() const noexcept {
      using namespace sml;
      return make_transition_table(
          // clang-format off
          // src    + event            = dst
          *state<A>                    = state<B>
          ,state<B> + event<evExit>    = X
          // clang-format on
      );
    }
  };

  struct StateMachine {
    auto operator()() const noexcept {
      using namespace sml;
      return make_transition_table(
          // clang-format off
          *state<Parent> + event<evExit> = X
          // clang-format on
      );
    }
  };

  sml::sm<StateMachine> sm;

  CHECK(sm.is(sml::state<Parent>));
  CHECK(sm.is<decltype(sml::state<Parent>)>(sml::state<B>));  // FAILS
  CHECK_FALSE(sm.is<decltype(sml::state<Parent>)>(sml::state<A>)); // FAILS
}

Specifications

  • Version: 1.1.3 (worked in 1.1.2)
  • Platform: Windows 32bit, both clang and MSVC

Rijom avatar Aug 11 '20 11:08 Rijom