Commit febb2fa
committed
fix: trim empty top-level else branches
Symptom: describe could emit an empty top-level `else` when the false branch pointed at a continuation that had already been emitted while traversing the true branch. Re-executing the MDL removed that empty branch, leaving a roundtrip mismatch.
Root cause: top-level IF traversal decided whether to emit `else` only by comparing `falseFlow.DestinationID` to the selected merge. That misses cases where the false destination is not the merge but traversal still emits no statements because the continuation is already visited.
Fix: mirror nested IF traversal: emit the `else` line tentatively, traverse the false branch, and remove the line again if the traversal produced no statements.
Tests: added a synthetic traversal regression test; `go test ./mdl/executor -run 'TopLevelIfRemovesEmptyElse|SequentialIfWithoutElse' -v`; `make build`; `make lint-go`; `make test`.1 parent 2991c12 commit febb2fa
2 files changed
Lines changed: 65 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
724 | 724 | | |
725 | 725 | | |
726 | 726 | | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
| 727 | + | |
| 728 | + | |
733 | 729 | | |
734 | 730 | | |
735 | 731 | | |
736 | 732 | | |
737 | 733 | | |
738 | 734 | | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
739 | 741 | | |
740 | 742 | | |
741 | 743 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
564 | 621 | | |
565 | 622 | | |
566 | 623 | | |
| |||
0 commit comments