Skip to content

Conversation

@vasdal
Copy link

@vasdal vasdal commented Nov 25, 2025

Problem:

  • When a state-specific transition exists but its guard condition returns false, the state machine does not fall back to try any_state (_) transitions for the same event
  • The event is consumed without any action being executed, even when a matching any_state transition exists

Solution:

  • Modified get_state_mapping in include/boost/sml.hpp to try any_state transitions when state-specific transitions fail
  • Uses aux::conditional_t to select at compile-time: combined_mapping (with || fallback) when any_state has real mappings, otherwise state_mapping directly
  • This avoids double-triggering unexpected_event handlers
  • Added test case any_state_fallback_when_guard_fails in test/ft/states.cpp to verify the fix

Reviewers:
@kris-jusiak

@vasdal vasdal changed the title fix: fallback to any_state when state-specific guard fails Fallback to any_state when state-specific guard fails Nov 25, 2025
@kris-jusiak kris-jusiak merged commit 9167ba4 into boost-ext:master Nov 25, 2025
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants