Skip to content

SMLv3: sml::variant<> must match sml::sm.states_ ordering #15

@jmcmullan

Description

@jmcmullan

The sml::variant<> must match the implicit ordering of the sml::sm.state_ member, or the wrong state will be decoded (as there is no causal relationship between an instanced sml::variant<> and the implicitly instanced sml::variant<> in the state machine sml::sm<> class)

The following diff illustrates this issue, by simply reordering the <s1, s2> types in the NTEST self-test (which then breaks the NTEST).

I'm at a loss as how to work around this given the current SMLv3 architecture (as at sml::overload{} constructor time, the sml::sm<> class doesn't exist).

diff --git sml sml
--- a/sml
+++ b/sml
@@ -602,12 +602,12 @@ static_assert(([] {
     unsigned calls{};
 
     sml::sm sm = sml::overload{
-      [&](s1, const e& event) -> sml::variant<s1, s2> {
+      [&](s1, const e& event) -> sml::variant<s2, s1> {
         if (event.value) {
           ++calls;
           return s2{};
         }
-        return {};
+        return s1{};
       },
     };
 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions