Commit a5c65df 1 parent 74f3e9a commit a5c65df Copy full SHA for a5c65df
File tree 1 file changed +8
-6
lines changed
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -4968,26 +4968,28 @@ def _verify_fallthrough_loop(self):
4968
4968
if not transition .is_fallthrough :
4969
4969
continue
4970
4970
4971
- # TODO: this should really be extracted into a method
4972
4971
visited = set ()
4972
+ def consider (transition ):
4973
+ return not any (x .get_target_override_mode () in [ActionOverrideMode .ALWAYS_GOTO_OTHER , ActionOverrideMode .ALWAYS_GOTO_UNDEFINED ] and transition .target not in x .get_target_override_targets () for x in transition .actions )
4974
+
4973
4975
def aux (x ):
4974
4976
if isinstance (x , DFConditionPoint ):
4975
4977
for i in x .transitions :
4976
4978
if i .target in visited :
4977
4979
continue
4978
- visited .add (i .target )
4979
- aux (i .target )
4980
+ if consider (i ):
4981
+ visited .add (i .target )
4982
+ aux (i .target )
4980
4983
else :
4981
4984
real_target = x [transition .on_values ]
4982
- if real_target and real_target .is_fallthrough :
4985
+ if real_target and real_target .is_fallthrough and consider ( real_target ) :
4983
4986
if real_target .target not in visited :
4984
4987
visited .add (real_target .target )
4985
4988
aux (real_target .target )
4986
4989
4987
4990
aux (state )
4988
4991
4989
- if state in visited and transition .is_fallthrough and not any (x .get_target_override_mode () in [
4990
- ActionOverrideMode .ALWAYS_GOTO_OTHER , ActionOverrideMode .ALWAYS_GOTO_UNDEFINED ] and state not in x .get_target_override_targets () for x in transition .actions ):
4992
+ if state in visited :
4991
4993
raise IllegalDFAStateError ("Infinite loop due to self-referential fallthrough" , transition )
4992
4994
4993
4995
You can’t perform that action at this time.
0 commit comments