Skip to content

Conversation

@rcosta358
Copy link
Collaborator

@rcosta358 rcosta358 commented Jan 29, 2026

This PR fixes some issues regarding the state machine diagram for typestates.

Multiple Initial States

Issue #43 mentioned the problem where we were only considering a single initial state, which is incorrect for example when we have overloading constructors that lead to a different initial state. This was fixed.

image

Hidden Loop Transitions

Issue #44 mentioned the problem where Mermaid only displayed a single self-transition when there were multiple ones, even with different labels. To fix this, all those transitions are merged into one single label.

image

Conditional Transitions

These were being completely ignored before. Now we add transitions of both then and else branches. In the future we might change this to support conditional transitions, e.g., cond ? then : else would create transitions cond && then and !cond && else, to better reflect the source code.

image

Copy link
Collaborator

@CatarinaGamboa CatarinaGamboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Add comment at the end before merging mention the issues that this PR closes.
In the future, lets try to tackle an issue at a time, but this is fine now

}
case Ite ite -> {
// combine states from then and else branches
// TODO: handle conditional transitions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets add this as an issue so we don't forget about it, one way to do it is adding the expression to the label like its done in symbolic automata

@rcosta358
Copy link
Collaborator Author

Closes #43 and #44.

@rcosta358 rcosta358 merged commit 335770c into main Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dfa enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DFA represent all loops or add a * mentioning there are more Show in state machine method overloading with different states

3 participants