Skip to content

Commit

Permalink
Event is no longer exposed for guards of eventless transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreDecan committed Jun 21, 2018
1 parent 21b87ec commit fc41d19
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

1.2.2 (2018-06-21)
------------------

- (Fixed) Event is not exposed when guard of eventless transitions are evaluated (regression
introduced in version 1.2.1).


1.2.1 (2018-06-19)
------------------

Expand Down
2 changes: 1 addition & 1 deletion sismic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__package__ = 'sismic'
__version__ = '1.2.1'
__version__ = '1.2.2'
__licence__ = 'LGPL3'
__author__ = 'Alexandre Decan'
__url__ = 'https://github.com/AlexandreDecan/sismic/'
Expand Down
7 changes: 5 additions & 2 deletions sismic/interpreter/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,18 @@ def _select_transitions(self, event: Event, states: List[str], *,
ignored_states = set() # type: Set[str]

# Select transitions according to the semantics
for _, transitions in groupby(considered_transitions, lambda t: t[0]): # event order
for eventless, transitions in groupby(considered_transitions, lambda t: t[0]): # event order
# Event shouldn't be exposed to guards if we're processing eventless transition
exposed_event = None if eventless else event

# If there are selected transitions (from previous group), ignore new ones
if len(selected_transitions) > 0:
break

# Remember that transitions are sorted based on event/eventless and the source state depth
for *_, transition in transitions:
if transition.source not in ignored_states:
if transition.guard is None or self._evaluator.evaluate_guard(transition, event):
if transition.guard is None or self._evaluator.evaluate_guard(transition, exposed_event):
# Add descendants/ancestors to ignored states
for state in ignored_state_selector(transition.source):
ignored_states.add(state)
Expand Down

0 comments on commit fc41d19

Please sign in to comment.