Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jmcmullan opened this issue Oct 15, 2024 · 0 comments
Open

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

jmcmullan opened this issue Oct 15, 2024 · 0 comments

Comments

@jmcmullan
Copy link

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{};
       },
     };
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant