When calling a linked ST via consecutive states, global tasks on the linked ST will not be initialized properly, which can lead to unintended behavior.
Specifically, when transitioning to the second instance of the linked state:
* A new global task will be created for the new instance of the linked ST (expected).
* The global task associated with the previous instance of the linked ST will not be destroyed.
* Exit State will not be called on the global task associated with the previous instance of the linked ST (unexpected).
* Enter State will not be called on the global task associated with the new instance of the linked ST (unexpected).
* The ST will reference the global task associated with the new global task instance (expected).
The workaround is to insert another dummy state between the two linked state executions. In the test project provided, I placed a delay of 1s in that state, but even transitioning immediately on tick will work.
In the case of a dummy state being present, the global tasks will be destroyed and created as I would expect for entering a new linked ST.
So I guess the question is - is this behavior by design? Intuitively it feels like every time we enter a new linked ST, regardless of it being consecutive or not, it should create a new global task for that ST and initialize it rather than holding onto the previous global task. Additionally, it does seem to use the new global task, but it does not initialize it properly, which feels like a bug. And I wouldn’t expect the presence of a dummy state to change how linked ST global tasks are initialized/destroyed.